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
 Import/Export (DTS) and Replication (2000)
 Cannot update identity column

Author  Topic 

vamsimahi
Starting Member

29 Posts

Posted - 2008-02-26 : 14:01:29
I want to write a stored procedure in DTS.
Where the task is to dump Orders table from Northwind Database to a New Database and also i need to change the OrderID, starting from 15000 instead of 10248.

I created a table in the new database and inserted the table from Northwind to new database .But , when i am trying to update the OrderID, i get the following error:

Cannot update identity column 'OrderID'



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-26 : 14:17:50
If you're doing this in stored procedure, use

SET IDENTITY_INSERT ON before the update statement and put it back to off once update is done by
SET IDENTITY_INSERT OFF

if you're doing update in DTS by means of export then check option "Enable identity insert".
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-02-26 : 14:47:56
You cannot update an identity column, with or without SET IDENTITY_INSERT on.

You need to set the value as you load the table, not update it after it is loaded.




set identity_insert NewTable on

insert into NewTable (...col list...)
select
ID = ID+SomeValue ,
...col list ...
from
OldTable

set identity_insert NewTable off



CODO ERGO SUM
Go to Top of Page
   

- Advertisement -