|
Posted by SQL Menace on 08/22/06 19:38
create a primary key or a unique constraint
ALTER TABLE [dbo].[YourTable] WITH NOCHECK ADD
CONSTRAINT [YourTable_PK] PRIMARY KEY CLUSTERED
(
[office code],
[office id],
[office section]
) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
or
ALTER TABLE dbo.YourTable ADD CONSTRAINT
IX_YourTable UNIQUE NONCLUSTERED
(
[office code],
[office id],
[office section]
) ON [PRIMARY]
Denis the SQL Menace
http://sqlservercode.blogspot.com/
HandersonVA wrote:
> Would anyone please instruct how to prevent the duplicate record by
> setting the unique keys on the ms sql server? i've been checking the
> duplicate record as front-end and i found out if there is an internet
> delay or some other reasons, it has a chance to store the duplicated
> data into the database. so i realized it has to be done on the back-end
> side.
> for example, if i have three columns (office code, office id, office
> section) as a unique key, how can i setup this? thanks in advance.
[Back to original message]
|