Solved

Bulk change auto-increment ID fields

Posted on 2006-11-14
4
224 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
  • 2
  • 2
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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 142

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now