troubleshooting Question

SQL DB Restore using OSQL

Avatar of Headmasters
HeadmastersFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL Server
2 Comments1 Solution282 ViewsLast Modified:
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

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros