Monday, March 26, 2012

restore database using OSQL

Dear Sir/Madam,

Would you please help me to create a batch file to restore a database from a file located on a remote path to my MSDE installed on my workstation.

the original database location was on the D drive on the server

but when i want to restore it to my MSDE it will be in a different path which is C

I want to create a command batch file by just double clicking on it, it will restore the database. (i want a forced restoration).

Please proivde me with your help.

Regards,

HotBirdLook up RESTORE DATABASE in BOL. It's all there.|||Please check this script is it runnable and right

OSQL -U sa - P xxxx RESTORE DATABASE mydb FROM DISK = '\\195.xxx.xxx.xxx\dolphindata\30704'
WITH REPLACE, MOVE 'mydb_Data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb_Data.MDF',MOVE 'mydb_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb_LOG.LDF' QUIT

I put this script in a file called "restore.bat"

Please advise me

Thanks in advance
HotBird|||Surround your RESTORE...by quotation marks and loose QUIT:

OSQL -U sa - P xxxx "RESTORE DATABASE mydb FROM DISK = '\\195.xxx.xxx.xxx\dolphindata\30704'
WITH REPLACE, MOVE 'mydb_Data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb_Data.MDF',MOVE 'mydb_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb_LOG.LDF'"

No comments:

Post a Comment