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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Current directory when restore (osql)
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 06/24/2006 :  10:37:07  Show Profile  Reply with Quote
When I do RESTORE FILELISTONLY FROM DISK = 'db.bak' I don't want to specify the path to the .bak file. Is there any way to do this? Something like '%CD%\db.bak'?! If I for example want to put MSDE, .bak and a script file (cmd) on a CD-r I want to install (and restore) the database from the current directory.


Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 06/24/2006 :  22:09:25  Show Profile  Reply with Quote
When you run a SQL RESTORE command, the command is executed in the context of the database service, not the user executing the OSQL command.

You will have to specify ths path of the backup file so that the database engine can find the file.

Go to Top of Page

Starting Member

2 Posts

Posted - 06/25/2006 :  06:46:31  Show Profile  Reply with Quote
Thank you for the answer. I worked around the problem by copy the .bak file in the cmd script first thing before starting the osql script. Then I got the current directory and then I know exactly were the file is :-)
Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000