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.
Author |
Topic |
freynoso
Starting Member
5 Posts |
Posted - 2008-06-04 : 16:07:13
|
Hi all.Thanks in advance for any help I could get after exposing my problem.First, I created an installer (with Inno Setup) where I developed some procedures to create a database at the moment of installation. In some cases (most of the time) I get an error message when trying to restore a backup from my DB.The error I get is that "the operating system returned the error: 5 (Access Denied)" when trying to read from the Backup file I copy (as a temporary file).In the beginning I didn't give that much attention to the error because I had some other priorities. But, today (6/4/2008), I got the same error when trying to restore another backup (from another application), but this time it happened in the SQL Management Studio (provided by Microsoft as a free administration tool).I don't have a clue about what I need to do to solve this problem and I'd like, some of you guys, to give me some advise about what is happening so I can understand what is going on.Thanks for any help (again).Fabio Reynoso |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-04 : 16:08:22
|
Could you post your query?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
|
|
freynoso
Starting Member
5 Posts |
Posted - 2008-06-04 : 17:12:18
|
This is the query I execute when trying to execute the "Restore" statement:SQLCommand := 'RESTORE DATABASE ' + Edit.Text + ' FROM DISK = ' + '''' + ExpandConstant('{tmp}') + '\DB.BAK' + '''' + ' WITH MOVE ' + '''' + 'BO_Data' + '''' + ' TO ' + '''' + MSSQLServerInstallPath + '\DATA\' + Edit.Text + '_Data.mdf' + '''' + ', MOVE '+ '''' + 'BO_Log' + '''' + ' TO ' + '''' + MSSQLServerInstallPath + '\DATA\' + Edit.Text + '_Log.ldf' + '''';It translates into this: RESTORE DATABASE <DBName> FROM DISK = 'DRIVE:\<TEMPDIR>\DB.BAK' WITH MOVE 'DB_DATA' TO '<SQLSERVERDEFAULTINSTALLDIR>\DATA\<NEWDBNAME>_DATA.MDF', MOVE 'DB_LOG' TO '<SQLSERVERDEFAULTINSTALLDIR>\DATA\<NEWDBNAME>_LOG.LDF'NOTE: Every <> symbol assumes the the value assigned through a variable's value.This is what I execute through my Installer. But it some cases (too few) it works OK.My second try (today) was directly working with SQL Server Management Studio, with a .BAK file, so there's no script involved.Thanks for your quick response Tara Kizer.FYI: SQL Server 2005 Express Edition SP2 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-06-04 : 23:03:46
|
If backup file is on remote location, sql service account needs permission to access it. |
|
|
freynoso
Starting Member
5 Posts |
Posted - 2008-06-05 : 01:08:24
|
Thanks again.Neither of both tries were done from remote location.Fabio. |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-06-05 : 22:32:14
|
Where is backup file? Did you try with straight command like:restore database db_name from disk = 'c:\file' with replace, move 'db_data' to 'c:\data\...', ... |
|
|
freynoso
Starting Member
5 Posts |
Posted - 2008-07-03 : 16:07:54
|
Sorry for the delay...I've already solved the problem I had with the Restore command.It was a problem related to the SQLEXPRESS service.Just to share... here's the solution:This problem seemed to be caused by the SQL Express service running as NT AUTHORITY\NetworkService. Change the service to run as the local system account, restart and the SQL Express restore should work properly.After doing that it should just be a case of restoring a SQL Server 2000 database as normal straight into SQL Server ExpressSource: http://www.sphericalsquare.net/knowledge/view/21/SQL_Express_Restore_FailedThanks anyway to all of you. |
|
|
|
|
|
|
|