?
Solved

sql mdf file attach error

Posted on 2010-09-07
6
Medium Priority
?
561 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 1000 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
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 
LVL 3

Assisted Solution

by:xiong8086
xiong8086 earned 1000 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 Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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…
Suggested Courses

770 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