1 minute google search gave me a page that I canβt display. Google it, and it will be your first link from 6/1/2009: tsql fix "identifier column"
Essentially, I would suggest adding a foreign key constraint between all of your relational fields in the identifier field in question before doing any renumbering (which is also a terrible idea if there is any relationship, strictly because if you ask this question, you will have a hell of a time).
If your contact table is ONLY your table or has a ZERO relationship based on this identifier field, you can set the Identity property to NO, renumber values ββfrom 1 to COUNT (ID), then set the Identity property to YES and re-fill the identifier to complete using:
DECLARE @MaxID INT
SELECT @MaxID = COUNT (ID) FROM TableID
CHECKIDENT DBCC ('TableID', RESEED, @MaxID)
In this case, you can use the above reseed script after each set of deletions (but change the value of COUNT (ID) to MAX (ID), as soon as everything is initially and correctly configured, this will add a bit of speed as the table grows), to any additional inserts or foreign key constraint restrictions. Make sure that you are using OPERATIONS wrapped around deletion and reuse blocks, and make sure the table only allows synchronous transactions, which will prevent any data hoses in the middle of repetitions.
Complex eh? That's why it's best to start with the right foot .;) (I have learned this from experience) Send me an email at mraarone et yahoo d0t com if you have any more questions.
Aaron
source share