UNIQUE KEY — HOW TO CREATE UNIQUE KEY ON A TABLE IN SQL SERVER 2005

–UNIQUE KEY — HOW TO CREATE UNIQUE KEY ON A TABLE

In order to create a unique key on a table you have to add a unique non clustured index.
Eg.

ALTER TABLE TABLENAME
ADD CONSTRAINT [CONSTRAINTNAME] UNIQUE NONCLUSTURED INDEX
(
[COLUMNNAME] ASC
)
WITH
SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF , ONLINE = OFF
ON
[PRIMARY]

Happy Programming
Pawan Kumar
pawankkmr@hotmail.com

Advertisements