dbTalk Databases Forums  

Identity reused problem

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Identity reused problem in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Marie-Christine Bechara
 
Posts: n/a

Default Identity reused problem - 03-12-2007 , 09:32 AM








I have a table with id an identity column.
Can I forbid the identity column of taking the same values of deleted
ones?

How can I resolve this issue?

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #2  
Old   
Greg D. Moore \(Strider\)
 
Posts: n/a

Default Re: Identity reused problem - 03-12-2007 , 10:10 AM






"Marie-Christine Bechara" <marie-christine.bechara (AT) ifsal (DOT) com> wrote in
message news:45f57272$0$502$815e3792 (AT) news (DOT) qwest.net...
Quote:

I have a table with id an identity column.
Can I forbid the identity column of taking the same values of deleted
ones?

How can I resolve this issue?

*** Sent via Developersdex http://www.developersdex.com ***
An Identity is always an increasing value unless you do a DBCC CHECKIDENT
call.

So already it avoids doing this.

--
Greg Moore
SQL Server DBA Consulting
Email: sql (at) greenms.com http://www.greenms.com




Reply With Quote
  #3  
Old   
Russ Rose
 
Posts: n/a

Default Re: Identity reused problem - 03-13-2007 , 11:08 PM




"Marie-Christine Bechara" <marie-christine.bechara (AT) ifsal (DOT) com> wrote in
message news:45f57272$0$502$815e3792 (AT) news (DOT) qwest.net...
Quote:

I have a table with id an identity column.
Can I forbid the identity column of taking the same values of deleted
ones?
There is no foolproof way since SET IDENTITY INSERT ON will allow reuse.

You could leave the records in place, using a deleted flag column to
indicate a logical deletion.

You could use an insert trigger to intercept id's that are below the max(id)
value.

You could use stored procedures and permissions to block the usage of the
identity insert.

Quote:
How can I resolve this issue?

*** Sent via Developersdex http://www.developersdex.com ***



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.