Tuesday, March 23, 2021

How to resolve issues while importing a DACPAC file during cloud migration which fails with kind of error Error SQL72014: or Error SQL72045: below:

 Many of the cloud migration issues are related to dacpac import for SQL server DB be it in Azure or AWS.


Below is one of them


*** Could not deploy package.

Error SQL72014: Core Microsoft SqlClient Data Provider: Msg 15007, Level 16, State 1, Line 1 'XYZReporting' is not a valid login or you do not have permission.

Error SQL72045: Script execution error.  The executed script:

CREATE USER [XYZReporting] FOR LOGIN [XYZReporting];


Just import the data with excluding the objects using the below switch:


PS C:\Program Files\Microsoft SQL Server\140\DAC\bin> .\sqlpackage /a:Publish /sf:C:\temp\db_test.dacpac /tsn:abxyz.cvvulhyblrdi.us-west-2.rds.amazonaws.com /tdn:demofin /tu:admin /tp:******  /p:ExcludeObjectTypes='Users;Logins;DatabaseRoles;RoleMembership;ServerRoleMembership;ServerRoles'