开发者

Identity column problem in SQL replication

How can we transfer primary key (iden开发者_JS百科tity column) while replicating a database.


You'll need to set the tables IDENTITY_INSERT to on and after everything is done turn it back off again.

SET IDENTITY_INSERT test ON

-- Inserts

SET IDENTITY_INSERT test OFF

But for more info and exceptions check this great article.
http://www.simple-talk.com/sql/database-administration/the-identity-crisis-in-replication/


If you're talking MySQL, a simple export/drop/create process should work just fine.


Remove the "identity" definition on your target table and you can copy directly from the source table. This will only work if the replication is one-way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜