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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Current directory when restore (osql)

Author  Topic 

Array
Starting Member

2 Posts

Posted - 2006-06-24 : 10:37:07
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.

Regards
Array

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-06-24 : 22:09:25
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.






CODO ERGO SUM
Go to Top of Page

Array
Starting Member

2 Posts

Posted - 2006-06-25 : 06:46:31
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
   

- Advertisement -