Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 How can I change identity seed of a identity field (runtime) ?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-11 : 10:58:56
DUY writes "I have 2 databases on 2 separate servers. Their structure is the same. I have a table and its primary key is an identity field. I want synchronize data between these 2 tables (between 2 databases). I have set identity seed for primary key of a table started from 1 and another one stared from 2000000. Now when I get data from the table which has identity field started from 2000000 and insert them into another one, it seems the identity seed value on the received table has been changed to value of identity field of the last inserted record (for example, If the last value is 2000000, the value of primary key of next record will be 2000001 instead of 2! I want the value must be 2).
Do we have any solutions for this problem ? Change identify seed on runtime, etc ..."

JamesT
Yak Posting Veteran

97 Posts

Posted - 2002-03-11 : 11:23:39
You can specify to have the identity values from table 1 be used and not generate new identity values on table 2. Look at books on line at: SET IDENTITY_INSERT

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-03-11 : 14:20:08
look at dbcc check_ident.
It allows you to change the seed.

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -