Wednesday, March 21, 2012

reset all identity seed in table

I mad a clone of my db and delete all info that I don't need.
how can I reset all identity seed in tables to the beginning numbers?
Tnx in advancedUse this
DBCC CHECKIDENT (Tablename, RESEED, 30)
Markus|||Use this
DBCC CHECKIDENT (Tablename, RESEED, 30)
Markus|||Use this
DBCC CHECKIDENT (tablename, RESEED,1)|||Have a look at DBCC CHECKIDENT in SQL Books OnLine
"John" <john@.smith.com> wrote in message
news:doe4gc$n4j$1@.news2.netvision.net.il...
> I mad a clone of my db and delete all info that I don't need.
> how can I reset all identity seed in tables to the beginning numbers?
> Tnx in advanced
>|||this only work for one table
I want it all :)
Tnx
"MarkusB" <m.bohse@.quest-consultants.com> wrote in message
news:1135253936.827451.60600@.f14g2000cwb.googlegroups.com...
> Use this
> DBCC CHECKIDENT (tablename, RESEED,1)
>|||If your tables are not referenced by foreign keys you could give this a try
:-
TRUNCATE TABLE tablename
this will remove all data and reset the identity column to it's seed value.
To run this against every table in your database make use of exec
sp_MSforeachtable
"John" <john@.smith.com> wrote in message
news:doe5om$na6$1@.news2.netvision.net.il...
> this only work for one table
> I want it all :)
> Tnx
> "MarkusB" <m.bohse@.quest-consultants.com> wrote in message
> news:1135253936.827451.60600@.f14g2000cwb.googlegroups.com...
> > Use this
> > DBCC CHECKIDENT (tablename, RESEED,1)
> >
>

No comments:

Post a Comment