Saturday, May 11, 2013

Unable to open physical file - Operating system error 5: 5(error not found) Microsoft SQL Server: Error 5120

Error:  Unable to open physical file - Operating system error 5: 5(error not found) Microsoft SQL Server: Error 5120

Reason of getting this Error: During attaching the database usually got this kind of error.

Work Around:
First we need to find out the service account which sql server runs under, here is the couple options for finding service account.


Option 1: Open SQL Server Configuration manager from start menu, and select sql server services, now you can see service account name on "Log On As" option below.



Option 2: Run below query on "new query window" and get the service account name.

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 (S/A) try the below steps to provide full privilege to files.
 
Step 1: Right click on the folder "" where the mdf and ldf files located and click on properties.

Step 2: Click on security tab.

Step 3: Click on Add button and add sql service account (S/A).

Step 4: Provide modify privilege and click ok.

Step 5: Verify both mdf and ldf have modify privilege.

Step 6: Attach the db!
Unable to open physical file - Operating system error 5: 5(error not found) Microsoft SQL Server: Error 5120. "Sql server error 5120". Error attaching database to Microsoft SQL Server 2005 in Windows. SQL Server 2008 - Attach mdf without log - Operating system error. sql - Error while attaching mdf file. Attach database failed for server. microsoft sql server 2012 errors. microsoft sql server 2015 errors. microsoft sql server 2008 r2 errors. 

0 comments:

Post a Comment