Cannot update identity column 'XXX'

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

猜你喜欢

转载自blog.csdn.net/wangyue4/article/details/44454171