Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 restore with T-SQL problem: db file names

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-21 : 08:26:09
Chuck writes "
I want to write a stored proc that will restore a database dump (eg. "CHUCK_TEST_2") to a differently named database (e. "CHUCK_TEST_1").

Here's the thing. When I use the SQL Server 7 Enterprise Manager to do this, upon successful restore, the logical database filenames retains the names they originally had (i.e. "CHUCK_TEST_1_Data", and "CHUCK_TEST_1_Log"). When I use T-SQL, upon successful restore, the logical database filenames now reflect those of the dump (i.e. database CHUCK_TEST_1 after successful restore now has the following logical database filenames: "CHUCK_TEST_2_Data", and "CHUCK_TEST_2_Log").

Here's my code:

RESTORE DATABASE CHUCK_TEST_1 FROM CHUCK_TEST_2_backup
WITH MOVE 'CHUCK_TEST_2_Data' TO 'D:\MSSQL7\data\CHUCK_TEST_1_Data.MDF',
/* does not work -- WITH MOVE 'CHUCK_TEST_1_Data' TO 'D:\MSSQL7\data\CHUCK_TEST_1_Data.MDF',*/
MOVE 'CHUCK_TEST_2_Log' TO 'D:\MSSQL7\data\CHUCK_TEST_1_Log.LDF',
/* does not work - MOVE 'CHUCK_TEST_1_Log' TO 'D:\MSSQL7\data\CHUCK_TEST_1_Log.LDF',*/
/*STANDBY = 'D:\MSSQL7\data\Undo_chuck.dat',*/
REPLACE"
   

- Advertisement -