SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 restore db to specific directory
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sirwan
Starting Member

Iraq
4 Posts

Posted - 05/04/2013 :  19:02:01  Show Profile  Reply with Quote
Hi all
How can i restore a data base to a specific directory like d:\db_name.mdf .
And i need to do this by code
?????

russell
Pyro-ma-ni-yak

USA
5072 Posts

Posted - 05/06/2013 :  11:53:53  Show Profile  Visit russell's Homepage  Reply with Quote
Use the WITH MOVE clause in your restore statement.
Go to Top of Page

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2067 Posts

Posted - 05/07/2013 :  01:47:57  Show Profile  Visit jackv's Homepage  Reply with Quote
use the RESTORE FILELISTONLY FROM DISK = 'H:\test1.bak' to identify the files currently in the backup file
Then construct a sql statement using something like:
RESTORE DATABASE Test
FROM DISK = 'F:\mybackup.bak'
WITH MOVE 'TestData' TO 'D:\test.MDF',
MOVE 'TestLog' TO 'E:\test.LDF'



Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

sirwan
Starting Member

Iraq
4 Posts

Posted - 05/15/2013 :  12:24:48  Show Profile  Reply with Quote
it work's Thank's :)
Go to Top of Page

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2067 Posts

Posted - 05/16/2013 :  01:43:22  Show Profile  Visit jackv's Homepage  Reply with Quote
your welcome

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000