BACPAC: Could not import package. SQL72012

%3CLINGO-SUB%20id%3D%22lingo-sub-103030%22%20slang%3D%22en-US%22%3EBACPAC%3A%20Could%20not%20import%20package.%20SQL72012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103030%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20SQL-guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20running%20into%20this%20error%20during%20the%20last%20days%20and%20could%20not%20find%20a%20solution%3A%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20import%20a%20database%20.BACPAC%20file%20from%20SQL%20Azure%20into%20my%20local%20SQL%20Server.%3C%2FP%3E%3CP%3EWhen%20doing%20so%2C%20I%20get%20this%20error%20on%20my%20local%20machine%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20not%20import%20package.%3CBR%20%2F%3EWarning%20SQL72012%3A%20The%20object%20%5Bmydb_Data%5D%20exists%20in%20the%20target%2C%20but%20it%20will%20not%20be%20dropped%20even%20though%20you%20selected%20the%20'Generate%20drop%20statements%20for%20objects%20that%20are%20in%20the%20target%20database%20but%20that%20are%20not%20in%20the%20source'%20check%20box.%3CBR%20%2F%3EWarning%20SQL72012%3A%20The%20object%20%5Bmydb_Log%5D%20exists%20in%20the%20target%2C%20but%20it%20will%20not%20be%20dropped%20even%20though%20you%20selected%20the%20'Generate%20drop%20statements%20for%20objects%20that%20are%20in%20the%20target%20database%20but%20that%20are%20not%20in%20the%20source'%20check%20box.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20this%20post%20(among%20with%20others...)%3A%3C%2FP%3E%3CP%3E%3CA%20title%3D%22https%3A%2F%2Fwww.sqlservercentral.com%2FForums%2FPrintTopic1886371.aspx%22%20href%3D%22https%3A%2F%2Fwww.sqlservercentral.com%2FForums%2FPrintTopic1886371.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.sqlservercentral.com%2FForums%2FPrintTopic1886371.aspx%3C%2FA%3E%3C%2FP%3E%3CDIV%20class%3D%22row%22%3E%3CDIV%3E%3CDIV%20class%3D%22posts%22%3E%3CDIV%20class%3D%22postBody%22%3E%3CP%3E%3C!--%20%20%20HTML5%20Shim%20and%20Respond.js%20IE8%20support%20of%20HTML5%20elements%20and%20media%20queries%20%20%20--%3E%3C!--%20%20%20WARNING%3A%20Respond.js%20doesn't%20work%20if%20you%20view%20the%20page%20via%20file%3A%2F%2F%20%20%20--%3E%3C!--%20%20%20Start%20custom%20code%20%20%20--%3E%3C!--%20%20%20AppInsights%2C%2025.08.2016%20%20%20--%3E%3C!--%20%20%20Cookies%2C%2026.04.2017%20%20--%3E%3C!--%20%20%20End%20custom%20code%20%20%20--%3E%3C%2FP%3E%3CDIV%20class%3D%22row%22%3E%3CDIV%3E%3CDIV%20class%3D%22posts%22%3E%3CDIV%20class%3D%22postBody%22%3E%3CP%3Esp_configure%20'contained%20database%20authentication'%2C%201%3B%3CBR%20%2F%3EGO%20%26nbsp%3B%3CBR%20%2F%3ERECONFIGURE%3B%3CBR%20%2F%3EGO%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInterestingly%2C%20this%20reconfiguration%20worked%20once%20some%20days%20ago%20with%20another%20database.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20now%2C%20I'm%20stuck%2C%20it%20doesn't%20work%20for%20me.%3C%2FP%3E%3CP%3E%5B%20I%20even%20installed%20the%20latest%20version%20of%26nbsp%3BSQL%20Server%20Management%20Studio%20(SSMS)%2017.2%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fssms%2Fdownload-sql-server-management-studio-ssms%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fssms%2Fdownload-sql-server-management-studio-ssms%3C%2FA%3E%20but%20without%20success.%20%5D%3C%2FP%3E%3CDIV%20class%3D%22row%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETips%20anyone%3F%3C%2FP%3E%3CP%3Ethx!%20Toni%26nbsp%3B%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-302940%22%20slang%3D%22en-US%22%3ERe%3A%20BACPAC%3A%20Could%20not%20import%20package.%20SQL72012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-302940%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20so%20much!%3C%2FP%3E%3CP%3EI%20used%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Esp_configure%20'contained%20database%20authentication'%2C%201%3B%20GO%20RECONFIGURE%3B%20GO%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Eto%26nbsp%3Benables%20contained%20databases%20on%20the%20instance%20of%20the%20Database%20Engine%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fdatabase-engine%2Fconfigure-windows%2Fcontained-database-authentication-server-configuration-option%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fdatabase-engine%2Fconfigure-windows%2Fcontained-database-authentication-server-configuration-option%3Fview%3Dsql-server-2017%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-107207%22%20slang%3D%22en-US%22%3ERe%3A%20BACPAC%3A%20Could%20not%20import%20package.%20SQL72012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-107207%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Fredrik%2C%3CBR%20%2F%3Eyes!%3CBR%20%2F%3EIt%20turned%20out%20that%20when%20I%20imported%20the%20same%20database%20into%20another%20SQL%20Azure%20Server%2C%20I%20received%20the%20following%20error%3A%3CBR%20%2F%3E%3CBR%20%2F%3ECould%20not%20import%20package.%3CBR%20%2F%3EError%20SQL72014%3A%20.Net%20SqlClient%20Data%20Provider%3A%20Msg%20468%2C%20Level%2016%2C%20State%209%2C%20Procedure%20vwSomeView%2C%20Line%203%3CBR%20%2F%3ECannot%20resolve%20the%20collation%20conflict%20between%20%22SQL_Latin1_General_CP1_CI_AS%22%20and%20%22Latin1_General_CI_AS%22%20in%20the%20UNION%20operation.%3CBR%20%2F%3EError%20SQL72045%3A%20Script%20execution%20error.%20The%20executed%20script%3A%3CBR%20%2F%3ECREATE%20VIEW%20%5Bdbo%5D.%5BvwSomeView%5D%20...%3CBR%20%2F%3E%3CBR%20%2F%3ESo%2C%20this%20lead%20me%20to%20the%20solution.%20Obviously%2C%20in%20my%20database%2C%20I%20added%20some%20new%20columns%20and%20that%20was%20done%20in%20with%20a%20different%20collation.%20That%20caused%20my%20errors.%3CBR%20%2F%3ETo%20make%20it%20short%2C%20my%20solution%20had%202%20parts%3A%3CBR%20%2F%3E1.%20%3CA%20href%3D%22https%3A%2F%2Fwww.sqlservercentral.com%2FForums%2FPrintTopic1886371.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.sqlservercentral.com%2FForums%2FPrintTopic1886371.aspx%3C%2FA%3E%3CBR%20%2F%3E2.%20I%20needed%20to%20convert%20all%20columns%20to%20the%20same%20collation%2C%20similar%20as%20here%3A%3CBR%20%2F%3EALTER%20TABLE%20MyTable%20ALTER%20COLUMN%20%5BMyColumn1%5D%20varchar(MAX)%20COLLATE%20Latin1_General_CI_AS%20NULL%3CBR%20%2F%3ESince%20this%20would%20mean%20a%20lot%20of%20effort%20I%20found%20a%20Stored%20Procedure%20script%20that%20runs%20through%20all%20tables%20and%20generates%20that%20ALTER%20script%20from%20%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F18122773%2Fchange-collations-of-all-columns-of-all-tables-in-sql-server%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F18122773%2Fchange-collations-of-all-columns-of-all-tables-in-sql-server%3C%2FA%3E%3CBR%20%2F%3EAfter%20These%20two%20steps%2C%20I%20regenerated%20the%20BACPAC%20and%20I%20was%20able%20to%20Import%20that%20database.%3CBR%20%2F%3EI%20hope%20I%20find%20some%20time%20to%20publish%20that%20in%20my%20blog%20in%20the%20next%20days%20to%20make%20a%20detailled%20description%20about%20my%20scenario.%3CBR%20%2F%3E%3CBR%20%2F%3EHope%20that%20helps%3F!%3CBR%20%2F%3Ebr%2C%20Toni%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-106275%22%20slang%3D%22en-US%22%3ERe%3A%20BACPAC%3A%20Could%20not%20import%20package.%20SQL72012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-106275%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20the%20exact%20same%20problem.%20Done%20the%20same%20upgrades%20as%20you%20and%20even%20upgraded%20my%20local%20SQL%20Server%20to%20the%20latest%20service%20pack%20(2016%20sp1).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDid%20you%20find%20any%20permanent%20solution%20for%20this%3F%20Have%20tried%20the%20above%20with%20no%20luck.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBr%2C%3C%2FP%3E%3CP%3EFredrik%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-104585%22%20slang%3D%22en-US%22%3ERe%3A%20BACPAC%3A%20Could%20not%20import%20package.%20SQL72012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-104585%22%20slang%3D%22en-US%22%3EHi%20all%2C%20I%20figured%20out%20that%20the%20reconfiguration%20works%20properly%20with%20_most_%20of%20my%20databases%20(but%20not%20all).%20So%20it%20seems%2C%20the%20issue%20is%20dependent%20on%20the%20database%20and%20the%20authentication%20used%20in%20there.%20Need%20to%20figure%20out%20a%20complete%20solution%20for%20that...%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1197862%22%20slang%3D%22en-US%22%3ERe%3A%20BACPAC%3A%20Could%20not%20import%20package.%20SQL72012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1197862%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Sir..%3C%2FP%3E%3CP%3ESir%20I%20am%20having%20the%20same%20problem....I%20am%20not%20able%20to%20import%20Bacpac%20file%20on%20my%20server%20instance%20which%20is%20sql%26nbsp%3B%20server%202012%20version.On%20my%20Local%20I%20have%20SQL%20SERVER%202014%20.I%20am%20using%20ssms%20of%20SQL%20Server%202014%20to%20connect%20to%20my%20Instance%20192.168.1.205.but%20I%20am%20getting%20this%20error.I%20have%20windows%2010%20on%20my%20local.I%20have%20even%20reconfigured%20for%20contained%20database.%20but%20no%20luck%20.please%20help%20me.Thanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1197863%22%20slang%3D%22en-US%22%3ERe%3A%20BACPAC%3A%20Could%20not%20import%20package.%20SQL72012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1197863%22%20slang%3D%22en-US%22%3ESame%20issue...and%20My%20boss%20is%20sitting%20on%20my%20head....%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1198101%22%20slang%3D%22en-US%22%3ERe%3A%20BACPAC%3A%20Could%20not%20import%20package.%20SQL72012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1198101%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Sir%20please%20tell%20me%20where%20do%20we%20run%20this%20reconfigure%20code%20....on%20the%20target%20server%20where%20we%20r%20trying%20to%20import%20the%20bacpac%20file....Pls%20answer.Thanks%3C%2FP%3E%3CP%3EI%20ran%20the%20same%20code%20on%20target%20server%20where%20we%20r%20trying%20to%20import%20the%20bacpac%20file%20but%20again%20the%20same%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eplease%20suggest..thanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
MVP

Hi SQL-guys,

 

I'm running into this error during the last days and could not find a solution:

I am trying to import a database .BACPAC file from SQL Azure into my local SQL Server.

When doing so, I get this error on my local machine:

 

Could not import package.
Warning SQL72012: The object [mydb_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 [mydb_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.

 

I found this post (among with others...):

https://www.sqlservercentral.com/Forums/PrintTopic1886371.aspx

sp_configure 'contained database authentication', 1;
GO  
RECONFIGURE;
GO

 

Interestingly, this reconfiguration worked once some days ago with another database.

 

But now, I'm stuck, it doesn't work for me.

[ I even installed the latest version of SQL Server Management Studio (SSMS) 17.2 from https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms but without success. ]

 

 

Tips anyone?

thx! Toni 

 

7 Replies
Highlighted
Hi all, I figured out that the reconfiguration works properly with _most_ of my databases (but not all). So it seems, the issue is dependent on the database and the authentication used in there. Need to figure out a complete solution for that...
Highlighted

Hi, 

 

I have the exact same problem. Done the same upgrades as you and even upgraded my local SQL Server to the latest service pack (2016 sp1).

 

Did you find any permanent solution for this? Have tried the above with no luck.

 

Br,

Fredrik

Highlighted

Hi Fredrik,
yes!
It turned out that when I imported the same database into another SQL Azure Server, I received the following error:

Could not import package.
Error SQL72014: .Net SqlClient Data Provider: Msg 468, Level 16, State 9, Procedure vwSomeView, Line 3
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the UNION operation.
Error SQL72045: Script execution error. The executed script:
CREATE VIEW [dbo].[vwSomeView] ...

So, this lead me to the solution. Obviously, in my database, I added some new columns and that was done in with a different collation. That caused my errors.
To make it short, my solution had 2 parts:
1. https://www.sqlservercentral.com/Forums/PrintTopic1886371.aspx
2. I needed to convert all columns to the same collation, similar as here:
ALTER TABLE MyTable ALTER COLUMN [MyColumn1] varchar(MAX) COLLATE Latin1_General_CI_AS NULL
Since this would mean a lot of effort I found a Stored Procedure script that runs through all tables and generates that ALTER script from https://stackoverflow.com/questions/18122773/change-collations-of-all-columns-of-all-tables-in-sql-s...
After These two steps, I regenerated the BACPAC and I was able to Import that database.
I hope I find some time to publish that in my blog in the next days to make a detailled description about my scenario.

Hope that helps?!
br, Toni

Highlighted

Thank you so much!

I used 

sp_configure 'contained database authentication', 1; GO RECONFIGURE; GO

 

to enables contained databases on the instance of the Database Engine

 

https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/contained-database-authentica...

Highlighted

Hello Sir..

Sir I am having the same problem....I am not able to import Bacpac file on my server instance which is sql  server 2012 version.On my Local I have SQL SERVER 2014 .I am using ssms of SQL Server 2014 to connect to my Instance 192.168.1.205.but I am getting this error.I have windows 10 on my local.I have even reconfigured for contained database. but no luck .please help me.Thanks

Highlighted
Same issue...and My boss is sitting on my head....
Highlighted

Hello Sir please tell me where do we run this reconfigure code ....on the target server where we r trying to import the bacpac file....Pls answer.Thanks

I ran the same code on target server where we r trying to import the bacpac file but again the same error.

 

 

please suggest..thanks