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 |
|
Eagle_f90
Constraint Violating Yak Guru
424 Posts |
Posted - 2011-10-26 : 20:43:01
|
| I have a column in my table named "LinkName" I want to force unique data in but do not want to use it as my PK. Can anyone tell me the alter table string to use to achive this?-- If I get used to envying others...Those things about my self I pride will slowly fade away.-Stellvia |
|
|
malpashaa
Constraint Violating Yak Guru
264 Posts |
Posted - 2011-10-26 : 21:41:05
|
Try this:ALTER TABLE TableName ADD CONSTRAINT ConstraintName UNIQUE(LinkName); |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-27 : 02:54:21
|
| Also keep in mind since its unique constraint that you're creating the column will still be able to store single instance of NULL value------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Eagle_f90
Constraint Violating Yak Guru
424 Posts |
Posted - 2011-10-27 : 09:56:51
|
| Thanks for the phrasing, Malpashaa. Visakh16, thanks for the note on null. I have already set the column to not allow nulls.-- If I get used to envying others...Those things about my self I pride will slowly fade away.-Stellvia |
 |
|
|
|
|
|