reset the Identity Seed

reset the Identity Seed

Post by <mani.. » Wed, 21 Mar 2001 15:45:33



Hi all,
I have 4 tables which i need to populate before populating a 5th table. All
these 4 tables have identity on their primary keys. I need to delete all the
rows from all these 4 tables each time before reinserting them.But due to
this the identity keeps on incrementing.Is there a way to reset the Identity
seed?? I cannot use the TRUNCATE TABLE method as i have foreign key
relationships between these tables.
 
 
 

reset the Identity Seed

Post by Tibor Karasz » Wed, 21 Mar 2001 16:24:32


Check out DBCC CHECKIDENT.

--
Tibor Karaszi, SQL Server MVP
FAQ from Neil at: http://www.sqlserverfaq.com
Please reply to the newsgroup only, not by email.


> Hi all,
> I have 4 tables which i need to populate before populating a 5th table. All
> these 4 tables have identity on their primary keys. I need to delete all the
> rows from all these 4 tables each time before reinserting them.But due to
> this the identity keeps on incrementing.Is there a way to reset the Identity
> seed?? I cannot use the TRUNCATE TABLE method as i have foreign key
> relationships between these tables.


 
 
 

reset the Identity Seed

Post by Andrew J. Kell » Wed, 21 Mar 2001 22:00:00


If you have RI issues and can't use TRUNCATE then how do you delete them? As
long as you truncate the tables from the Child tables first and the parents
last you should be all set.

--
Andrew J. Kelly
Targitmail.com


Quote:> Hi all,
> I have 4 tables which i need to populate before populating a 5th table.
All
> these 4 tables have identity on their primary keys. I need to delete all
the
> rows from all these 4 tables each time before reinserting them.But due to
> this the identity keeps on incrementing.Is there a way to reset the
Identity
> seed?? I cannot use the TRUNCATE TABLE method as i have foreign key
> relationships between these tables.