Solved

sql mdf file attach error

Posted on 2010-09-07
6
546 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
Comment Utility
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
Comment Utility
In administrative tools > services > try to run the MSSQL service under local system account it should work.

0
 
LVL 2

Expert Comment

by:SrinathKomirishetty
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 3

Assisted Solution

by:xiong8086
xiong8086 earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
mdf AND ldf solved it.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Read about achieving the basic levels of HRIS security in the workplace.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
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…

744 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

15 Experts available now in Live!

Get 1:1 Help Now