Blocking duplicates in access from SQL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My table resides in a SQL database: It has two fields:
1. NameID - KEY 2. Name
I want the user to have the ability to add new names in an Access form and
disallow any names that already exist. SQL does not give me the ability to
set the Name field to 'No Duplicates' and Access does not let me set the NO
DUP property since this is a linked table.

What code or settings is required to disallow duplicates in a no-key field
between Access and SQL?
 
I don't have an SQL server in front of me right now... but I think you can
disallow duplicates by playing with an index and setting it to 'no
duplicates'. Let me know if you can't find it and I'll look further when
I'm at work.... is it SQL 2K?
 
You can create a constraint in Sql on that column. You can run a script
below from the query anaylizer to create the constraint.

ALTER TABLE [YourTableName] ADD CONSTRAINT [YourIndexName] UNIQUE
NONCLUSTERED
(
[YourColumnName]
) ON [PRIMARY]
GO

After this script is run Sql server will refuse to allow Duplicates in the
YourColumnName column of table YourTableName.

Ron W
 
Back
Top