?
Solved

Bulk change auto-increment ID fields

Posted on 2006-11-14
4
Medium Priority
?
242 Views
Last Modified: 2006-11-18
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
Comment
Question by:moruda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 17940785
you could do this:
exec sp_msforeachtable ' DBCC CHECKIDENT ( ''?'' , RESEED , 600000 ) '

0
 

Author Comment

by:moruda
ID: 17940944
if i need to, could i have it run only on specific tables?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17941019
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
 

Author Comment

by:moruda
ID: 17941122
great
thanks!
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question