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 |
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2008-09-10 : 06:40:08
|
| I have a field in a table made up as follows XX1D*01/01/2008. I have made it the key but it allows duplicates - how do I set it to not allow duplicates. Identity is greyed out. |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-10 : 07:27:42
|
| not clearVed Prakash Jha |
 |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-09-10 : 07:42:18
|
| I tried followingCreate table #T( job varchar(30) Unique)Insert INTO #T values ('XX1D*01/01/2008')Insert INTO #T values ('XX1D*01/01/2008')On running second Insert, I got Msg 2627, Level 14, State 1, Line 1Violation of UNIQUE KEY constraint 'UQ__#T________________5629CD9C'. Cannot insert duplicate key in object 'dbo.#T'.Can you provide table structure you are using? |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2008-09-10 : 08:02:39
|
| How do I make it unique through the properties ? The table is already created and holds data |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-09-10 : 08:22:05
|
| Delete duplicates and then set unique constraint. |
 |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-09-10 : 08:24:48
|
| ALTER TABLE yourtable ADD CONSTRAINT ID_UNIQ_1 UNIQUE (Columnname)Also, look for WITH NOCHECK in BOL if you want to keep already existing duplicate data. |
 |
|
|
|
|
|