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 |
|
larrythek
Starting Member
7 Posts |
Posted - 2008-01-22 : 10:29:09
|
| Absolute SQL Beginner hereI am using SQL Server 2005 Express Edition in conjunction with asp.net 2.0Is there any way to guarantee when INSERTing data, that all values in a given column (which is of a char data type) are unique? Or do I have to do this programatically at the asp layer?Thanks in advanceLarry |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-01-22 : 10:31:06
|
You can add a UNIQUE INDEX or a UNIQUE CONSTRAINT for the column in mind.If a duplicate value is inserted, the DB will generate an error for you. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-01-22 : 10:31:25
|
| You can place unique constraint on the desired column at table level.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
larrythek
Starting Member
7 Posts |
Posted - 2008-01-22 : 10:36:40
|
| Thanks Peso for your reply...but I'm still confusedCan I do this with a Column property when I establish the table definition? I don't see anything there that applies.Or must this constrain be applied when an INSERT is executed. If so, can you show me the syntax?ThanksLarry |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-01-22 : 10:40:04
|
CREATE UNIQUE INDEX IX_BlaBlaBla ON MyTable (MyColumn) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|