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.
精彩评论