Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql mdf file attach error

Posted on 2010-09-07
6
Medium Priority
?
563 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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…

609 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