【发布时间】:2018-08-07 15:21:44
【问题描述】:
我从 azure sql db 创建了一个 bacpac,将其复制到 blob,然后从 blob 将其在本地下载。
我在 powershell 中运行这段代码
Add-Type -path "C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\Microsoft.SqlServer.Dac.dll"
$restoredDatabaseName = 'AuditTest'
$bacpacFile = "H:\backup\audit\audit.bacpac"
$conn = "Data Source=.;Initial Catalog=master;Connection Timeout=0;Integrated Security=True;"
$importBac = New-Object Microsoft.SqlServer.Dac.DacServices $conn
$loadBac = Microsoft.SqlServer.Dac.BacPackage::Load($bacpacFile)
$importBac.ImportBacpac($loadBac, $restoredDatabaseName)
#Clean up
$loadBac.Dispose()
恢复这个错误:
Microsoft.SqlServer.Dac.BacPackage::Load : The term 'Microsoft.SqlServer.Dac.BacPackage::Load' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
我也尝试使用导入数据层向导,但出现以下错误。
Could not load file or assembly 'Microsoft.SqlServer.Dac, Version=13.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. (Microsoft.SqlServer.Management.Dac.DacWizard)
这让我发疯了,我发现了一些关于注册表黑客等向导错误的事情,对 powershell 没有任何帮助。
SQL Azure DB PRS1 在 Azure VM 中恢复到 SQL 2016。
【问题讨论】:
标签: powershell azure-sql-database sql-server-2016