Azure-Sql-Database

創建 bacpac 失敗 (DoAllowRowLocks / DoAllowPageLocks)

  • August 4, 2014

我正在從本地數據庫創建一個 bacpac 文件以導入到 Azure SQL Server,但我不斷收到一個似乎無法解決的錯誤。

Error SQL71564: Element Primary Key has an unsupported property DoAllowRowLocks set and is not supported
   when used as part of a data package. 
Error SQL71564: Element Primary Key has an unsupported property DoAllowPageLocks set and is not supported
   when used as part of a data package.

這個錯誤會重複50多個鍵。我已經全職專注於這個問題兩天了,我真的很想在這個問題上得到一些幫助。

我已經使用這些腳本解決了問題:

$$ Rebuild all indexes $$

USE AdventureWorks;
declare @table_name varchar(200)
declare @SQL varchar(300)

DECLARE vendor_cursor cursor 
       FOR SELECT sys.tables.name
       FROM sys.tables WHERE sys.tables.name NOT LIKE '%_dss'
OPEN vendor_cursor

FETCH NEXT FROM vendor_cursor 
INTO @table_name

WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @SQL =  'ALTER INDEX ALL ON '+@table_name+' REBUILD';
EXEC(@SQL);
print 'INDEX Rebuild on all indexes in table '+@table_name+' is done.';
FETCH NEXT FROM vendor_cursor  INTO @table_name
END 
CLOSE vendor_cursor;
DEALLOCATE vendor_cursor;
GO

我還需要更改 IsNotForReplication 屬性。對於所有具有標識列的表,此腳本將其變為 YES。

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

對於所有具有標識列的表,此腳本將其變為 NO。

EXEC sp_msforeachtable @command1 = ‘
declare @int int
set @int =object_id(“?”)
EXEC sys.sp_identitycolumnforreplication @int, 0′

引用自:https://dba.stackexchange.com/questions/50561