0
我使用powershell從bacpac文件創建SQL Azure數據庫。但是,有時我會在數據庫大小超過默認最大大小時遇到麻煩。數據庫大小過大時,Powershell importBacpac到Azure會失敗?
根據文檔,應該可以將DB大小添加到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()
}