Quantcast
Channel: SQL Server Manageability forum
Viewing all articles
Browse latest Browse all 1519

Restore-SQLDataBase

$
0
0

Hi There

I'm trying to restore a SQL DB that we have from our PROD DB (MYDB) environment  to our Test DB (MYBD_TEST) environment  using the powershell cmd-let Restore-SqlDatabase see code below

$SQLBackupFile = "\\server1\Share\MYDB.bak"
$RelocateData = New-Object Microsoft.SqlServer.Management.Smo.RelocateFile("MYDB_Restore", "S:\MSSQL12.MSSQLSERVER\MSSQL\DATA\MY_Restore.mdf")
$RelocateLog = New-Object Microsoft.SqlServer.Management.Smo.RelocateFile("MYDB_Restore_Log", "S:\MSSQL12.MSSQLSERVER\MSSQL\DATA\MYDB_Restore_log.ldf")

Restore-SqlDatabase -ServerInstance server -Database MYDB_Restore -BackupFile $SQLBackupFile -RelocateFile @($RelocateData,$RelocateLog)

I get the below error message

Restore-SqlDatabase : System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing 'MYDB_TEST' database.

Some help with this would be great.

Cheers,


Viewing all articles
Browse latest Browse all 1519

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>