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 |
|
WBuik
Starting Member
2 Posts |
Posted - 2007-05-19 : 23:03:09
|
I have a table in MSSQL 2005 Express that stores user data. I would like to maintain the cases of user names, but I need to insure that they are not duplicated using different cases. Is there a way that I can create a constraint to enforce this?Thanks ,WBuik |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-05-20 : 00:45:43
|
| Yes if the column has case-insensitive collation. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-20 : 09:25:02
|
| if the column is case insenstive then a simlpe check likewhere yourColumn = 'yourUserNameHere'will suffice._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-05-20 : 16:52:32
|
| [code]CREATE TABLE MyTable( ... MyUserName varchar(1234) COLLATE xxxx ...)[/code]choose appropriate collation "xxxx" for your desired character set, make sure you choose a Case Sensitive (and whether you want Accent Sensitive, or not), then put a Unique Index on that column.Kristen |
 |
|
|
WBuik
Starting Member
2 Posts |
Posted - 2007-05-31 : 16:53:55
|
| Thanks, this worked great. |
 |
|
|
|
|
|