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
 General SQL Server Forums
 Database Design and Application Architecture
 check for unique value from sqlmanager

Author  Topic 

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2010-02-27 : 22:09:09
Hi.I was wondering if there is a way to tell the sql to check for nvarchar values to be unique in a column without the use of a query.
Thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-27 : 23:04:29
you could create a unique index/constraint on the column for that

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2010-02-27 : 23:38:25
Hi.
Yes but does it work for character data?If the sting is the same but it's like 'hello' and 'HeLlo'
?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-27 : 23:56:33
quote:
Originally posted by sapator

Hi.
Yes but does it work for character data?If the sting is the same but it's like 'hello' and 'HeLlo'
?


it will work provided you use a case insensitive collation.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2010-02-28 : 20:38:17
Hmm.
Have to check to dev pc tomorrow.
It's LAtin or Greek but i don't recall the ASCII.
Thank will try it.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-02-28 : 21:43:20
It's preferred to use a unique constraint instead of a unique index. You get an index on a unique constraint already and a constraint is helpful to define the data integrity. If you just used an index, you wouldn't see it in a reverse engineered ERD; but you would with a constraint.

I don't ever use unique indexes. I always use unique constraints.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2010-03-01 : 21:49:14
Hi.Works fine for upper and lower.Thanks for the help.
Although i'm not sure what collation is theoretically used.
The column collation is SQL_Latin1_General_CP1_CI_AS and the database collation is Greek_CI_AS
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-01 : 23:41:06
CI stands for case insensitive, so you are good.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2010-03-02 : 11:32:30
All right.
Thanks :)
Go to Top of Page
   

- Advertisement -