We have the following dead-simple restore code:
Restore DATABASE MyDataBaseName with Recovery
I want to turn the above TSQL into powershell (or whatever other Programming language through SMO)
I have the following code:
Above code gives me the following error:
"Exception calling "SqlRestore" with "1" argument(s): "Restore failed for Server [server name]"
I know if I were to do an actual restore, I would have to specify the restore file etc... but all I want is "Restore database with Recovery"...
any ideas?
Restore DATABASE MyDataBaseName with Recovery
I want to turn the above TSQL into powershell (or whatever other Programming language through SMO)
I have the following code:
Code:
$restore = new-object Microsoft.SqlServer.Management.Smo.Restore
$restore.Database = $databaseName
$restore.ReplaceDatabase = $replace
$restore.Action = "Database"
$restore.NoRecovery = $false
$server = New-Object ("Microsoft.sqlserver.management.smo.server") ("MyServer")
$restore.SqlRestore($server)
"Exception calling "SqlRestore" with "1" argument(s): "Restore failed for Server [server name]"
I know if I were to do an actual restore, I would have to specify the restore file etc... but all I want is "Restore database with Recovery"...
any ideas?