December 15, 2003 at 8:27 am
I am deleting rows out of a table, when I insert values back in the primary key is starting the number 1 + the last one that was deleted. I deleted 57 rows, when I inserted the values the primary key started counting at 58 and went to 115. Is there a simple procedure or function that does this?
December 15, 2003 at 8:36 am
If you want again a starting value of 1, take a look at BOL for DBCC CHECKIDENT.
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 15, 2003 at 9:02 am
Truncate table also resets identities
December 15, 2003 at 9:09 pm
Alternatively, after performing the delete, go into EM, design table and set the Identity Seed of the primary key to something else (eg 2) and click on Save. Then set the Identity Seed back to 1, Save again, and your numbering will again start from 1.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
December 17, 2003 at 10:34 am
simple advice:
don't be bothered by autogenerated numbers, you'll not care for GUIDs you generate as well, would you?
deleting rows when using IDENTITY always will give you "holes" in your sequence, but why think about it? it will not impact functionality!
and lastly: the correct term is "constraint" 😉
best regards,
chris.
December 23, 2003 at 11:17 am
You seem to be using the "Identity" column for more than "Idnetity". Can you explain why? Their are many ways to generate a series of integers, terporary or permanant. You might want to consider an alternative to altering the identity column.
-Isaiah
-Isaiah
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply