SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

mohan123
Constraint Violating Yak Guru

India
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
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
Flowing Fount of Yak Knowledge

3760 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. http://msdn.microsoft.com/en-us/library/ff878058.aspx
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8768 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  
 New 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.03 seconds. Powered By: Snitz Forums 2000