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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 reseeding Identity Values for selected Tables

Author  Topic 

mohan123
Constraint Violating Yak Guru

252 Posts

Posted - 2013-07-11 : 08:47:14
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
DBCC CHECKIDENT (Table_1, RESEED, @last)


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

P.V.P.MOhan

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-07-11 : 09:07:26
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. http://msdn.microsoft.com/en-us/library/ff878058.aspx
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-07-11 : 09:28:28
google for
sp_MSForEachTable reseed


Too old to Rock'n'Roll too young to die.
Go to Top of Page
   

- Advertisement -