all groups > sql server programming > june 2004 >
You're in the

sql server programming

group:

How to reset the identity value to 1 after all rows have been deleted?


Re: How to reset the identity value to 1 after all rows have been deleted? Dan Guzman
6/5/2004 5:15:22 PM
sql server programming:
You can either truncate the table or run DBCC CHECKIDENT with the RESEED
option. See the Books Online for details.

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

Re: How to reset the identity value to 1 after all rows have been deleted? Dan Guzman
6/5/2004 8:59:47 PM
Glad it helped.

--
Dan Guzman
SQL Server MVP

How to reset the identity value to 1 after all rows have been deleted? Oscar
6/5/2004 11:12:20 PM
After that I deleted all rows within a table which holds an identity column,
I want to have the next inserted row to start with the ID = 1 value.
However, SQL Server 2K assigns an ID value to the identity column which is
one higher that the ID-value of the last row that was deleted. How can I
reconfigure the column such that the first additional row should have an
ID=1 value ?

Oscar

Re: How to reset the identity value to 1 after all rows have been deleted? Oscar
6/6/2004 1:09:10 AM
Thanks Dan,

both options solved the matter.


"Dan Guzman" <danguzman@nospam-earthlink.net> schreef in bericht
news:uGZFZq0SEHA.3692@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Re: How to reset the identity value to 1 after all rows have been deleted? Joe Celko
6/6/2004 8:29:06 AM
I'll bet that you are mimicking a sequential file system.

Can you explain why you have an IDENTITY column in the first, in
relational terms? Surely you know better than to use it as a key, since
it cannot ever be a key by definition. But if you made it a PRIMARY KEY
by mistake then what does resetting it with new data mean in relational
terms?

This question is a veryu good sign that you are doing everything wrong.

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Devdex http://www.devdex.com ***
AddThis Social Bookmark Button