You can create a new db then use the "Restore Wizard" enabling the Overwrite option or:
View the contents of the backup file:
RESTORE FILELISTONLY FROM DISK='c:your.bak'
note the logical names of the .mdf & .ldf from the results, then:
RESTORE DATABASE MyTempCopy FROM DISK='c:your.bak'
WITH
MOVE 'LogicalNameForTheMDF' TO 'c:MyTempCopy.mdf',
MOVE 'LogicalNameForTheLDF' TO 'c:MyTempCopy_log.ldf'
This will create the database MyTempCopy
with the contents of your.bak
.
(Don't create the MyTempCopy, it's created during the restore)
Example (restores a backup of a db called 'creditline' to 'MyTempCopy'):
RESTORE FILELISTONLY FROM DISK='e:mssqlackupcreditline.bak'
>LogicalName
>--------------
>CreditLine
>CreditLine_log
RESTORE DATABASE MyTempCopy FROM DISK='e:mssqlackupcreditline.bak'
WITH
MOVE 'CreditLine' TO 'e:mssqlMyTempCopy.mdf',
MOVE 'CreditLine_log' TO 'e:mssqlMyTempCopy_log.ldf'
>RESTORE DATABASE successfully processed 186 pages in 0.010 seconds (144.970 MB/sec).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…