Win*_*oek 19 sql-server azure-sql-database
我使用“任务”>“导出数据层应用程序”将我的 Azure 数据库导出到 .bacpac 文件中。最近当我尝试将其导入本地数据库服务器(任务 > 导入数据层应用程序)时,遇到了这个错误:
Could not import package.
Warning SQL72012: The object [MyDatabase_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 [MyDatabase_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 12824, Level 16, State 1, Line 5 The sp_configure value 'contained database authentication' must be set to 1 in order to alter a contained database. You may need to use RECONFIGURE to set the value_in_use.
Error SQL72045: Script execution error. The executed script:
IF EXISTS (SELECT 1
FROM [master].[dbo].[sysdatabases]
WHERE [name] = N'$(DatabaseName)')
BEGIN
ALTER DATABASE [$(DatabaseName)]
SET CONTAINMENT = PARTIAL
WITH ROLLBACK IMMEDIATE;
END
Error SQL72014: .Net SqlClient Data Provider: Msg 5069, Level 16, State 1, Line 5 ALTER DATABASE statement failed.
Error SQL72045: Script execution error. The executed script:
IF EXISTS (SELECT 1
FROM [master].[dbo].[sysdatabases]
WHERE [name] = N'$(DatabaseName)')
BEGIN
ALTER DATABASE [$(DatabaseName)]
SET CONTAINMENT = PARTIAL
WITH ROLLBACK IMMEDIATE;
END
(Microsoft.SqlServer.Dac)
Run Code Online (Sandbox Code Playgroud)
我遵循了其他帖子的建议,并尝试在 SQL Azure 数据库上运行它:
sp_configure 'contained database authentication', 1;
GO
RECONFIGURE;
GO
Run Code Online (Sandbox Code Playgroud)
然而,它说
Could not find stored procedure 'sp_configure'.
Run Code Online (Sandbox Code Playgroud)
我了解 Azure 中的等效语句是:https : //docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-scoped-configuration-transact-sql? view = sql-server- 2017
“sp_configure 'contained database authentication', 1;”的等效语句是什么?
Win*_*oek 32
解决方案是针对master本地/内部部署 SQL Server的数据库执行此操作:
sp_configure 'contained database authentication', 1;
GO
RECONFIGURE;
GO
Run Code Online (Sandbox Code Playgroud)
感谢David Browne - Microsoft和Alberto Morillo提供的快速解决方案。
我遇到了同样的问题,通过命令提示符导入 bacpac 解决了这个问题。在链接Import Bacpac中,转到 SQLPackage 部分并运行那里提供的命令。
sqlpackage.exe /a:import /tcs:"Data Source=<serverName>.database.windows.net;Initial Catalog=<migratedDatabase>;User Id=<userId>;Password=<password>" /sf:AdventureWorks2008R2.bacpac /p:DatabaseEdition=Premium /p:DatabaseServiceObjective=P6
Run Code Online (Sandbox Code Playgroud)