Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Unique Constraint on Two Columns

Author  Topic 

Stanley Tan
Starting Member

25 Posts

Posted - 2002-10-20 : 07:21:39
Hi,

Is it possible to have a unique constraint across two columns? For example:

A B
-- ---
BS BIO
BS BIO

If I tried to insert the second row, it would fail. Is this possible? :)

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-10-20 : 07:55:19
Yes.

Go to Top of Page

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2002-10-20 : 07:59:03
Sure,

alter table t add constraint ABUnique Unique(A,B)

Go to Top of Page

Stanley Tan
Starting Member

25 Posts

Posted - 2002-10-21 : 04:35:23
quote:

Sure,

alter table t add constraint ABUnique Unique(A,B)





Seems easy enough :) Thanks! Can I do this with Enterprise Manager? (Hehe, getting lazy).

Go to Top of Page
   

- Advertisement -