• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

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!
0
moruda
Asked:
moruda
  • 2
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now