Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 reseeding Identity Values for selected Tables
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

252 Posts

Posted - 07/11/2013 :  08:47:14  Show Profile  Reply with Quote
hello all,

how to reseed for selected basing on their last count.I have written a query to to reseed basing on last count.But for how to do 10 tables at a time .

declare @last int
select @last=max(empid) from Table_1

but how to do for more than 10 tables or more tables...reseeding at one go basing on last count


James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 07/11/2013 :  09:07:26  Show Profile  Reply with Quote
There is no command that allows you to set the identity seed for multiple tables at the same time. You will have to do the reseeding one at a time.

Are you trying to manage a group of ten tables such that the next insert to any one of those tables would draw from the same pool of sequence numbers? If you are, you might want to investigate the SEQUENCE object. It is available only in SQL 2012 though.
Go to Top of Page

Flowing Fount of Yak Knowledge

8781 Posts

Posted - 07/11/2013 :  09:28:28  Show Profile  Visit webfred's Homepage  Reply with Quote
google for
sp_MSForEachTable reseed

Too old to Rock'n'Roll too young to die.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000