[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Bulk change auto-increment ID fields

Posted on 2006-11-14
4
Medium Priority
?
247 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

649 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