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 |
willworkforfoodjnr
Starting Member
2 Posts |
Posted - 2007-07-19 : 03:04:30
|
Hi everyoneI have a varchar column which may, or may not, contain a userID value. I want some way of saying "If the column has a value, it must be unique" But I can't find any way of doing it without SQL complaining about duplicate null values. Is there a way of doing this?Thanks! |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-19 : 05:31:14
|
http://weblogs.sqlteam.com/mladenp/archive/2007/05/17/60209.aspx_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-19 : 06:06:50
|
quote: Originally posted by spirit1 http://weblogs.sqlteam.com/mladenp/archive/2007/05/17/60209.aspx_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp
The page is not displayedMadhivananFailing to plan is Planning to fail |
 |
|
willworkforfoodjnr
Starting Member
2 Posts |
Posted - 2007-07-19 : 06:13:01
|
Fast reply, and it works great, thanks! |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-19 : 06:16:43
|
> The page is not displayedworks fine for me... can you se it if you refresh?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-19 : 07:05:55
|
quote: Originally posted by spirit1 > The page is not displayedworks fine for me... can you se it if you refresh?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp
Yes it works. It seems internet problem MadhivananFailing to plan is Planning to fail |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-07-23 : 13:23:07
|
"Fast reply, and it works great, thanks!"We used to use this solution but got fed up with the requirements for ANSI flag settings etc.Now we use a Trigger to enforce uniqueness on non-NULL values in a column.Kristen |
 |
|
X002548
Not Just a Number
15586 Posts |
|
Kristen
Test
22859 Posts |
Posted - 2007-07-24 : 03:23:45
|
For completeness see also:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=Can't+insert+NULL+into+table+with+unique+key |
 |
|
|
|
|