Link to home
Start Free TrialLog in
Avatar of Headmasters
HeadmastersFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL DB Restore using OSQL

Hi,

I'd like to restore a sql database using OSQL but seem to be running into a few problems:

The sql database was originally backed up on a different machine the MDF files were located in a different location and the Database name was different.

Backed up From:
Database Name: Experts
Database Path: c:\Program Files\Experts Directory\Experts_Data.MDF
Database Path: c:\Program Files\Experts Directory\Experts_Log.LDF
Backup FIle: C:\Backup\Experts.BAK

Restore To:
Database Name: Exchange
Database Path: C:\Program Files\Exchange Directory\Exchange_Data.MDF
Database Path: C:\Program Files\Exchange Directory\Exchange_Log.LDF
Restore from: C:\Backup\Experts.BAK

I am using the following command but am running into problems:

osql -SDBServer -E -Q " RESTORE DATABASE Experts FROM DISK = 'C:\Backup\Expert.Bak' WITH MOVE 'C:\Program Files\Experts Directory\Experts_data.mdf' TO 'C:\Program Files\Exchange Directory\Exchange_Data.mdf', MOVE 'C:\Program Files\Experts Directory\Experts_log.ldf' TO 'C:\Program Files\Exchange Directory\Exchange_log.ldf' "

I did manage to restore the database using a graphical interface in enterprise manager.

Any help would be gratefully appreciated.

Many Thanks

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Headmasters

ASKER

Thank you very much!