When importing a Exported SQL Azure DB to a local SQL server instance you may see this error. In short the reason for this error is that the DB being exported was in active use at the time of the export. The data in the Database was active changing as Azure was exporting it and this can cause data inconsistency. The export functionality does not guarantee transactional consistency.
If there are foreign key relationships between tables and there is inconsistency in the table data, the import will show an error when foreign key constraints are being re-nabled after the import.
How to fix/avoid this problem?
1. Fix the offending data rows
2. Make a copy of the Azure DB and export from the copy. The copy function essentially takes a snapshot of the DB and gurantees transactional consistency. Obviously, the bacpac export file won’t have all the data after the copy was created.
TITLE: Microsoft SQL Server Management Studio
Could not import package.
Warning SQL72012: The object [CRTM_Demo_Data] exists in the target, but it will not be dropped even though you selected the ‘Generate drop statements for objects that are in the target database but that are not in the source’ check box.
Warning SQL72012: The object [CRTM_Demo_Log] exists in the target, but it will not be dropped even though you selected the ‘Generate drop statements for objects that are in the target database but that are not in the source’ check box.
Error SQL72014: .Net SqlClient Data Provider: Msg 547, Level 16, State 0, Line 3 The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “FK_dbo.Address_dbo.CoolRunningsBaseType_Id”. The conflict occurred in database “CRTM_Demo”, table “dbo.CoolRunningsBaseType”, column ‘Id’.
Error SQL72045: Script execution error. The executed script:
PRINT N’Checking constraint: FK_dbo.Address_dbo.CoolRunningsBaseType_Id [dbo].[Address]’;
ALTER TABLE [dbo].[Address] WITH CHECK CHECK CONSTRAINT [FK_dbo.Address_dbo.CoolRunningsBaseType_Id];