我使用 powershell 从 bacpac 文件创建 SQL Azure 数据库。但是,当数据库大小超过默认的最大大小时,有时我会遇到麻烦。
根据文档,应该可以将数据库大小添加到 ImportBacpac 方法,但我不确定如何在 powershell 中使用它。
任何正在使用更改的数据库最大大小恢复数据库的人?
文档:http ://technet.microsoft.com/en-us/library/jj870786.aspx
当前代码
function restore-SQLBackup
([string]$ConnectionString = $(throw "The ConnectionString parameter is required."),
[string]$DatabaseName = $(throw "The databaseName parameter is required."),
[string]$fileName = $(throw "The fileName parameter is required."),
[string]$microsoftSqlServerDacPath = "C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Microsoft.SqlServer.Dac.dll") {
Add-Type -Path $microsoftSqlServerDacPath
$Services = new-object Microsoft.SqlServer.Dac.DacServices $ConnectionString
if ($Services -eq $null)
{
exit
}
$timeStamp = (Get-Date).ToString("yyyy-MM-dd_HH-mm-ss")
$bacpac = [Microsoft.SqlServer.Dac.BacPackage]::Load($fileName)
Write-Host "Starting restoring $DatabaseName at $timeStamp"
$Watch = New-Object System.Diagnostics.StopWatch
$Watch.Start()
$Services.ImportBacpac($bacpac, $DatabaseName)
$Watch.Stop()
Write-Host "Restore completed in" $Watch.Elapsed.ToString()
}