Azure SQL 数据库同步列不允许空值警告

Azure SQL Database SYNC column does not allow nulls warning

我设置了一个 Microsoft SQL 数据同步代理作业来将我们的本地服务器同步到 Azure。它运行良好,然后我们在本地进行了一些更新,它没有从 Azure 中删除已删除的行,现在同步失败并显示警告:

Sync completed with warnings in 708.02 seconds. 
Upload:   4646 changes applied/155 failed   
Download: 680 changes applied/0 failedData Sync will stop synchronizing changes for this sync group member in -60 days if the failures are not resolved.    
Upload - errors for first 5 rows that failed to apply:Error #1: SqlException Error Code: -2146232060 - 
SqlError Number:515, Message: Cannot insert the value NULL into column 'ModelID', table 'dbo.ModelYears'; column does not allow nulls. INSERT fails. 
SqlError Number:3621, Message: The statement has been terminated. Error #2: SqlException Error Code: -2146232060 - 
SqlError Number:515, Message: Cannot insert the value NULL into column 'ModelID', table 'dbo.ModelYears'; column does not allow nulls. INSERT fails. 
SqlError Number:3621, Message: The statement has been terminated. Error #3: SqlException Error Code: -2146232060 - 
SqlError Number:515, Message: Cannot insert the value NULL into column 'ModelID', table 'dbo.ModelYears'; column does not allow nulls. INSERT fails. 
SqlError Number:3621, Message: The statement has been terminated. Error #4: SqlException Error Code: -2146232060 - 
SqlError Number:515, Message: Cannot insert the value NULL into column 'ModelID', table 'dbo.ModelYears'; column does not allow nulls. INSERT fails. 
SqlError Number:3621, Message: The statement has been terminated. Error #5: SqlException Error Code: -2146232060 - 
SqlError Number:515, Message: Cannot insert the value NULL into column 'ModelID', table 'dbo.ModelYears'; column does not allow nulls. INSERT fails. 
SqlError Number:3621, Message: The statement has been terminated.     
For more information, provide tracing ID ‘92002a08-b374-4579-b58c-a5164e820767’ to customer support.

ModelID 列在任一 table 上都不允许为空值,所以我不确定是什么导致了错误。

我按照一个论坛的建议截断了 Azure 上的 ModelYears_dss_tracking 和 ModelYears,它确实重新填充了 tables,但它仍然发出警告。

能否请您确认是否更改了此table的PK?

消除错误的一种快速方法是 1)删除同步组 2) 删除集线器和成员上架构 'DataSync' 下的所有 tables 和 SP 3) 删除触发器包含单词 'dss' 4) 再次创建同步组

此致, 加里

我有一个比批准的更好的解决方案(不那么激进)。

使用这种方法,您将不需要删除整个同步组。

批准的解决方案之所以有效,是因为您正在刷新整个副本,但如果您已经有大量信息怎么办?重做所有可能需要永远。

解决一个table的方法只有:

  1. 确保在执行这些步骤时您的副本已关闭

  2. 这里使用@denise提供的脚本LINK 请记住,要小心,该脚本使用 LIKE 语句,因此请确保您只获得一个结果。

  3. 删除该结果中提供的所有对象。 如果你现在运行你的副本,它会失败说找不到程序,所以不要这样做!,

  4. 打开“TABLES”,刷新架构,然后 UNSELECT table 你有问题,按保存。

  5. 再次打开“表”,刷新模式以防万一,SELECT table 你有问题,按保存。

  6. 现在您可以安全地启动副本,它将为失败的 table 重新创建丢失的对象。