• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 976
  • Last Modified:

Need T-SQL for to restore and rename database in one step.

Hello.  Using SQL 2000 I need to restore a database to a different database name and move the .mdf and .ldf files to a different location.  I'm getting an error with the code below.   I am doing this one time with many databases and do not wish to use the task wizard in Enterprise Manager.

Please correct :)
RESTORE DATABASE sp_rename(ComcastVOD,ComcastVodTest)
FROM DISK = 'F:\temprestsource\ComcastVODBackup111308.bak'
WITH MOVE 'ComcastVOD_Data' TO 'F:\temporaryrestore\ComcastVOD_Data.MDF',
MOVE 'ComcastVOD_Log' TO 'F:\temporaryrestore\ComcastVOD_Log.LDF'

Open in new window

0
Lawrence Barnes
Asked:
Lawrence Barnes
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you give the restore database name you want:
RESTORE DATABASE ComcastVodTest
FROM DISK = 'F:\temprestsource\ComcastVODBackup111308.bak'
WITH MOVE 'ComcastVOD_Data' TO 'F:\temporaryrestore\ComcastVOD_Data.MDF',
MOVE 'ComcastVOD_Log' TO 'F:\temporaryrestore\ComcastVOD_Log.LDF'

Open in new window

0
 
Lawrence BarnesAuthor Commented:
Thank you
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now