Avatar of MatthewOsosky
MatthewOsosky
Flag for United States of America asked on

sql mdf file attach error

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
Microsoft SQL ServerDatabases

Avatar of undefined
Last Comment
MatthewOsosky

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Raja Jegan R

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
shalabhsharma

In administrative tools > services > try to run the MSSQL service under local system account it should work.

SrinathKomirishetty

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
SOLUTION
xiong8086

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
xiong8086

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
MatthewOsosky

ASKER
mdf AND ldf solved it.