IdentityIsNotForReplication on SQL Server database primary keys prevent migration to SQL Azure

StackOverflow https://stackoverflow.com/questions/22876055

سؤال

I have a SQL Server database that is the end result of replication. In other words, it's just the copy. I would like to migrate this database to SQL Azure, using either Management Studio or as a BACPAC file. Attempting this I get the things I expected, like needing a clustered index, for example, but the thing I'm stuck on is that the primary keys on every table (and there are a lot of them) all have the following error:

IdentityIsNotForReplication is set and is not supported when used as part of a data package.

OK, cool, but that's a property of a .NET abstraction around schema, and as far as I can tell, not something I can change from T-SQL. I'm a little stuck!

هل كانت مفيدة؟

المحلول

NOT FOR REPLICATION is a property that can be applied to triggers, constraints and identity columns to prevent replicating them. You can set this property ON and OFF.

Here's a piece of T-SQL code to turn off NOT FOR REPLICATION for all tables:

EXEC sp_msforeachtable @command1 = '
declare @int int
set @int =object_id("?")
EXEC sys.sp_identitycolumnforreplication @int, 0'

(Addapted from http://blogs.msdn.com/b/repltalk/archive/2012/03/06/marking-identity-columns-as-not-for-replication-in-existing-publication.aspx)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top