Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Strange File issue > "CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file" Expand / Collapse
Author
Message
Posted Thursday, August 8, 2013 9:26 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 18, 2014 1:14 PM
Points: 9, Visits: 90
Recently I have had to move and restructure my SQL farms and environment. I had detached a SolarWinds database called NetPerfMon that consisted of three data (mdf) files and one log(ldf) file. The database detached without issue.

Today one of my engineers needed to retrieve some data and when I went to restore it I found the files still there. That's great I thought. Just re-attach. Then I received this error:

"CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'd:\userdbs\pathToFile.mdf'"

I listed the files and database names from sys.databases and this database is DEFINITELY not loaded in to SQL. When I looked at all the open file handles with Sysinternals "Handle.exe", it lists the netperfmon mdf files as being open by the SQL server process.

This server has been rebooted several times during the move since I dropped the original database. Why (WHY!?!?) would SQL still have these files open?

I already worked around the issue by restoring it somewhere else but I'm dying of curiosity....why would SQL have these files open when the database is not currently attached to the system and hasn't been for several starts? Also why when attaching to an EXISTING file would it be trying to create the data file as it indicates in the error?





Post #1482404
Posted Thursday, August 8, 2013 12:58 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, July 1, 2014 3:20 AM
Points: 196, Visits: 650
The restore executing user doesn't have permissions on that folder. I had the same issue earlier when I attempted to backup a database to the F: drive. Copy the files to %SQL_HOME%\Backup and try to do it again, it should work then.

Edit: It's either a problem reading the file or the location you're specifying the new data files to go (by the fact it says "create").

Try a restore verifyonly on the datafile to identify which part of the restore you're having problems with (if the verifyonly is successful then it's the creation location).



Dird // Junior DBA
11g OCA
10.5 newbie
Post #1482533
Posted Thursday, August 8, 2013 3:39 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 12:01 PM
Points: 1,948, Visits: 2,882
I had detached a SolarWinds database called NetPerfMon that consisted of three data (mdf) files and one log(ldf) file.


That might be the problem. Detaching a db in SQL 2005 and later versions changes the permissions on the file. So it might be a permissions issue trying to read the existing files.

For that reason and others, I suggest using "SET OFFLINE" instead of detaching whenever you can.


SQL DBA,SQL Server MVP('07, '08, '09)
"In America, every man is innocent until proven broke!" Brant Parker
Post #1482589
Posted Sunday, August 18, 2013 7:21 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 18, 2014 1:14 PM
Points: 9, Visits: 90
Sorry for the late reply. Been in the middle of a data center move and well...you know how that can be.

Thank you for your responses. I think you kinda missed my question though. I'm not really interested in why SQL couldn't attach to the files. I worked around that like I said. What my question is is was this:

"When I looked at all the open file handles with Sysinternals "Handle.exe", it lists the netperfmon mdf files as being open by the SQL server process.

This server has been rebooted several times during the move since I dropped the original database. Why (WHY!?!?) would SQL still have these files open? "


What I am trying to say there is that SQL doesn't show the db as attached/loaded and its not listed in sys.databases however the OS is telling me that the SQL process has the files open. So why would the SQL process have handles to these files if it is not using them? Even after two reboots.

Thanks again....
Post #1485632
Posted Monday, August 19, 2013 2:28 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 10:29 AM
Points: 1,223, Visits: 9,618
kenneth.gore (8/18/2013)
So why would the SQL process have handles to these files if it is not using them? Even after two reboots.


Can't think of any logical reason if they're not registered with the instance.

Are you sure they're not part of a different DB than you're expecting? Do they appear anywhere in this output:

SELECT physical_name, DB_NAME(database_id) Database_Name FROM sys.master_files

Post #1485684
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse