Unix Technical Forum

Identity reused problem

This is a discussion on Identity reused problem within the SQL Server forums, part of the Microsoft SQL Server category; --> I have a table with id an identity column. Can I forbid the identity column of taking the same ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 02:40 PM
Marie-Christine Bechara
 
Posts: n/a
Default Identity reused problem



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 ***
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 02:40 PM
Greg D. Moore \(Strider\)
 
Posts: n/a
Default Re: Identity reused problem

"Marie-Christine Bechara" <marie-christine.bechara@ifsal.com> wrote in
message news:45f57272$0$502$815e3792@news.qwest.net...
>
>
> 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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 02:41 PM
Russ Rose
 
Posts: n/a
Default Re: Identity reused problem


"Marie-Christine Bechara" <marie-christine.bechara@ifsal.com> wrote in
message news:45f57272$0$502$815e3792@news.qwest.net...
>
>
> 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.

>
> How can I resolve this issue?
>
> *** Sent via Developersdex http://www.developersdex.com ***



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:05 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com