File activation failure. The physical file name “C:\Program Files\Microsoft SQL Server\Path…” may be incorrect. The log cannot be rebuilt when the primary file is read-only.


As we have a new version of Adventureworks database for SQL Server 2012 RC 0 I wanted to start my testing on the same.I downloaded the mdf file from the Codeplex site.

As this is only the MDF file without LDF I went ahead and tried a attach(Attach Databases option) by removing the LDF file which will ensure that we will get a new LDF created automatically.

Right away I was hit hard by a strange error which said

The physical file name path looked strange to me as I did not had such a path in my server.I tried multiple ways to attach the mdf without an ldf including

EXEC sp_attach_single_file_db @dbname = 'AdventureWorks2008R2',
@physname = 'C:\SQL_Data\AdventureWorks2008R2_Data.mdf'

and also using FOR ATTACH_REBUILD_LOG method which Pinal Dave(@pinaldave) clearly explained through his blog post here

Both time same error mentioned above came yet again

File activation failure. The physical file name “C:\Program Files\Microsoft SQL Server\MSSQL11.DENALIRCO\MSSQL\DATA\AdventureWorks2008R2_log.ldf” may be incorrect.

The log cannot be rebuilt when the primary file is read-only.

Msg 1813, Level 16, State 2, Line 1

Could not open new database ‘AdventureWorks2008R2’. CREATE DATABASE is aborted.

 Solution –  I had a strong feeling that this might be really related to a permission issue and the error message is little mis-leading rather than the actual issue. I went ahead and checked the rights for the Data folder where the mdf file was placed and after re-evaluating and granting permissions to proper SQL accounts the database was attached using normal attach method.

 Conclusion – So next time when you hit this error,remember to have a look at the permissions too for the Data file folder.
Thanks for reading.
Advertisement

20 thoughts on “File activation failure. The physical file name “C:\Program Files\Microsoft SQL Server\Path…” may be incorrect. The log cannot be rebuilt when the primary file is read-only.

    • Have you read the section ‘Solution’ which was mentioned in the post.

      You will have to check the rights for the Data folder where the mdf file is placed and after re-evaluating and granting permissions to proper SQL accounts the database will be attached using normal attach method.

    • make a folder and put the sample mdf file ” c:\sql_data\adventureworks2012.mdf ” then right click on sql_data then go to security and click the correspoding user and give full controls. then query create database adventure works2012
      on(filename=’c:\sql_data\adventureworks2012.mdf’)
      for attach_rebuild_log;

      • Yes,Security needs to be verified here and proper permission should be granted as mentioned in the ‘Solution’ section of the post.You can either use GUI to do the attach or using T-SQL code as you mentioned by you.Both works after correct permissions are set.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s