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.
| Author |
Topic |
|
kiranmurali
Yak Posting Veteran
55 Posts |
Posted - 2011-03-10 : 02:03:41
|
| hi all,I have a senario thati my table there are three fields,orgid lobid locationid1 1 41 1 5i want to bulild a unique constarint in suvh a way that locationid should not repeat same for the combination of (orgid & lobid)pls any can help me to solve this situationRegards,Kiranmayee |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2011-03-10 : 02:47:48
|
| You can create a unique constraint for all the 3 columns. |
 |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-03-10 : 02:50:58
|
| Use the following if table not created or If the table is created,respectively. create table xyz(col1 int, col2 int, col3 int, CONSTRAINT uc_col1_col2_col3 UNIQUE (Col1,col2,col3))Or Alter table xyz add CONSTRAINT uc_col1_col2_col3 UNIQUE (Col1,col2,col3)CheersMIK |
 |
|
|
|
|
|