Bulk change auto-increment ID fields

Hi,
we need to replicate a new database and would like to change the auto-increment on all columns with autonumber to a different seed to properly setup the merge replication.
is there some type of script we can execute to go through all columns in all tables and do this automatically to any auto-incremented field?

THANKS!
morudaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you could do this:
exec sp_msforeachtable ' DBCC CHECKIDENT ( ''?'' , RESEED , 600000 ) '

0
 
morudaAuthor Commented:
if i need to, could i have it run only on specific tables?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
of course. you can put any logic in the the ' sql ' part you want.
however, I think it would be better (professional) to setup the list of tables and their new values, generate the script from there, and run the script...
0
 
morudaAuthor Commented:
great
thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.