August 14, 2010 at 12:46 pm
Comments posted to this topic are about the item Duplicate value in Identity column
Cheers
August 15, 2010 at 10:17 pm
hi,
I know that we can add explicit values to an identity column using
Identity_Insert on. but i thought that identify column will not allow duplicate columns.good question.lost one point but learned one new point.
Malleswarareddy
I.T.Analyst
MCITP(70-451)
August 15, 2010 at 11:06 pm
good one... duplicates can only be avoided by having a constraint in place...
August 16, 2010 at 12:26 am
Nice question. Usually an Identity column is used as a primary key (and thus having a unique clustered index), which will prevent the insertion of duplicate values.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
August 16, 2010 at 1:25 am
ziangij (8/15/2010)
good one... duplicates can only be avoided by having a constraint in place...
...or by having a unique index in place.
Best Regards,
Chris Büttner
August 16, 2010 at 1:41 am
And i thought i only didnt knew it 🙂
Cheers
August 16, 2010 at 4:57 am
Good Question...
Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
August 16, 2010 at 6:26 am
I have to admint I wouldn't have gotten this one right, except for a similar question a few months ago. I still don't understand why one would want to create an identity and then break the rules of the identity. Seems like trouble 🙂
August 16, 2010 at 6:43 am
Identity insert can be very dangerous. For a long time I couldn't see a use for it. Then I needed it to get 2 tables in 2 different databases into sync after they had fallen out of sync for some unknown reason. It saved me a lot of effort.
August 16, 2010 at 7:09 am
Only one person can insert identity on a column at a time, so WE can not... :hehe:
August 16, 2010 at 7:56 am
Yes you can insert but should be avoided by having a unique constraint or Pkey on identity column.
Since, it doesn't make much sense, if you want to put duplicate value in identity column then why add identity option to column int. Just leave it as is.
SQL DBA.
August 16, 2010 at 8:39 am
SanjayAttray (8/16/2010)
Since, it doesn't make much sense, if you want to put duplicate value in identity column then why add identity option to column int. Just leave it as is.
I think the idea behind this question is to warn people that just using IDENTITY is not enough. Not everybody knows that duplicate entries can still happen with an IDENTITY, so that is a valuable lesson learned with this question.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
August 16, 2010 at 8:39 am
Interesting. Very surprised to learn you can enter duplicate values when inserting explicit values.
Further surprised to learn that you can get duplicate values by resetting the identity seed, according to this person:
August 16, 2010 at 8:50 am
Nice question.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
August 16, 2010 at 2:08 pm
SanjayAttray (8/16/2010)
Yes you can insert but should be avoided by having a unique constraint or Pkey on identity column.Since, it doesn't make much sense, if you want to put duplicate value in identity column then why add identity option to column int. Just leave it as is.
Perhaps Microsoft should change it so that a PK or unique constraint must accompany an identity column? Like you say, it doesn't make sense to have it this way and is a potential problem.
Viewing 15 posts - 1 through 15 (of 28 total)
You must be logged in to reply to this topic. Login to reply