June 2008
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Search

 
Catagories
Archives
Recent Entries
Links
RSS
adding a composite column constraint
Catagory: sql server · This Entry · Comment(0) · eMail entry · Google
March 16, 2004 04:27 PM

sql server

unique constraints are actually implemented as indexes really, so it might not be obvious where to go to do this in enterprise manager.

to add a unique composite column constraint in sql server, you can bring up the design table dialog (right click on the table) in enterprise manager, then click on indexes and keys.


add a new index, and in the table column list
add the columns you want
then select 'create unique', and choose 'constraint'.

in Transact SQL -- it's something like this...

ALTER TABLE [dbo].[mytable] WITH NOCHECK ADD
CONSTRAINT [IX_mytable] UNIQUE NONCLUSTERED
(
[column1],
[column2]
) ON [PRIMARY]


simple no?





Comments

Post a comment
Name:


Email Address:


URL:


Comments: