Solved

sql mdf file attach error

Posted on 2010-09-07
6
548 Views
Last Modified: 2012-05-10
I have a set of mdf and ldf files given to me by a client. I open sql server express management studio and try to attach the mdf files as a database. I recieve an error "Unable to open physical file blah\blah\blah operating system error 5: (access is denied) (Microsoft SQL Error: 5120)

The file is not open in any other program, and all permissions are applied to the file.

Why would this be happening, how to fix?

Thanks,
Matthew
0
Comment
Question by:MatthewOsosky
6 Comments
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 250 total points
ID: 33623823
Make sure that the startup account of SQL Server services has access to the folder and mdf and ldf files.
If so, then copy mdf and ldf files to Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data

and then try attaching the file which should work.
0
 
LVL 9

Expert Comment

by:shalabhsharma
ID: 33624092
In administrative tools > services > try to run the MSSQL service under local system account it should work.

0
 
LVL 2

Expert Comment

by:SrinathKomirishetty
ID: 33624229
Use the below script to find the sql service account

 

Code Snippet

declare @sqlser varchar(20)

EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key='SYSTEM\CurrentControlSet\Services\MSSQLSERVER',

@value_name='objectname', @value=@sqlser OUTPUT

PRINT 'Account Starting SQL Server Service:' +convert(varchar(30),@sqlser)

 

 

After getting the service account try the below steps to provide privilege

 

    *
      Right click on the folder C:\ArrowSQL\Arr@Data and click on properties
    *
      Click on security tab
    *
      Click on Add button and add sql service account
    *
      Provide modify privilege and click ok
    *
      Verify both mdf and ldf have modify privilege
    *
      Attach the db!


or  Refer  http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/9e563890-e35f-4524-82b9-3cca08fec5ed
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 3

Assisted Solution

by:xiong8086
xiong8086 earned 250 total points
ID: 33624767
change the security of the mdf file and ldf file received. authorize your current user with full access.
0
 
LVL 3

Expert Comment

by:xiong8086
ID: 33624788
you may need to check whether you have already got same database running.

when you re-attach, just open the options tab to see the path is correct or not, maybe the Drive letter need to be changed.
0
 
LVL 1

Author Closing Comment

by:MatthewOsosky
ID: 33626976
mdf AND ldf solved it.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now