locked
Attaching a database RRS feed

  • Question

  • I ran the following code and got the error message listed below it.  Is there a way to attached the database?

    CREATE DATABASE semanticsdb ON
     (FILENAME = 'C:\Program Files\Microsoft Semantic Language Database\semanticsdb.mdf'),
     (FILENAME = 'C:\Program Files\Microsoft Semantic Language Database\semanticsdb_log.ldf')
     FOR ATTACH;
    GO

    Msg 3415, Level 16, State 2, Line 2
    Database 'semanticsdb' cannot be upgraded because it is read-only, has read-only files or the user does not have permissions to modify some of the files. Make the database or files writeable, and rerun recovery.


    Thursday, December 18, 2014 10:49 PM

Answers


  • >>Database 'semanticsdb' cannot be upgraded because it is read-only, has read-only files or the user does not have permissions to modify some of the files. Make the database or files writeable, and rerun recovery.


    I think the files are readonly( as you are trying to attach the database), You may have to provide proper permission on the files and verify that the SQL Server Service logon account has write access to the files

    Satheesh
    My Blog | How to ask questions in technical forum

    • Proposed as answer by Donghui Li Monday, December 22, 2014 1:49 AM
    • Marked as answer by Donghui Li Friday, December 26, 2014 1:44 AM
    Friday, December 19, 2014 8:52 AM
    Answerer
  • Hello Stephen,

    See Database [databasename] cannot be upgraded because it is read-only or has read-only files with the same issue & how to solve it; the access (read/write) permissions for the SQL Server Service account is missing.


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    • Proposed as answer by VSPatel Friday, December 19, 2014 9:41 AM
    • Marked as answer by Donghui Li Friday, December 26, 2014 1:44 AM
    Friday, December 19, 2014 7:21 AM
  • Hi, stephen

    as other stated above ,make sure your SQL Server Service logon account has proper right

    to access the data files

    i think you should check the attribute of  directory which the mdf file and ldf file laying

    i have suffered a situation before, the attribute of the directory  which the mdf file and ldf file were  laying on  has been set to readonly due to the database attach failed

    and then i removed the readonly attribute of the directory,and added everyone right to the directory

    after the setting, the attaching of database gone fine

    thanks

    • Proposed as answer by Donghui Li Monday, December 22, 2014 1:50 AM
    • Marked as answer by Donghui Li Friday, December 26, 2014 1:44 AM
    Friday, December 19, 2014 9:15 AM
  • Please change the locations of MDF and LDF and retry. And also make sure the required privileges to your account are in place.

    Regards, Pradyothana DP http://www.dbainhouse.blogspot.in/ Please Mark This As Answer if it solved your issue.

    • Marked as answer by Donghui Li Friday, December 26, 2014 1:44 AM
    Friday, December 19, 2014 10:34 AM

All replies

  • Hi Stephen,

    You have to run this script before you can alter the existing the database as it is in read-only mode

    USE [master]
    GO
    ALTER DATABASE [Semanticsdb] SET  READ_WRITE WITH NO_WAIT
    GO

    Thanks

    Bhanu


    • Edited by bhanu_nz Thursday, December 18, 2014 11:27 PM
    Thursday, December 18, 2014 11:27 PM
  • Hello Stephen,

    See Database [databasename] cannot be upgraded because it is read-only or has read-only files with the same issue & how to solve it; the access (read/write) permissions for the SQL Server Service account is missing.


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    • Proposed as answer by VSPatel Friday, December 19, 2014 9:41 AM
    • Marked as answer by Donghui Li Friday, December 26, 2014 1:44 AM
    Friday, December 19, 2014 7:21 AM

  • >>Database 'semanticsdb' cannot be upgraded because it is read-only, has read-only files or the user does not have permissions to modify some of the files. Make the database or files writeable, and rerun recovery.


    I think the files are readonly( as you are trying to attach the database), You may have to provide proper permission on the files and verify that the SQL Server Service logon account has write access to the files

    Satheesh
    My Blog | How to ask questions in technical forum

    • Proposed as answer by Donghui Li Monday, December 22, 2014 1:49 AM
    • Marked as answer by Donghui Li Friday, December 26, 2014 1:44 AM
    Friday, December 19, 2014 8:52 AM
    Answerer
  • Hi, stephen

    as other stated above ,make sure your SQL Server Service logon account has proper right

    to access the data files

    i think you should check the attribute of  directory which the mdf file and ldf file laying

    i have suffered a situation before, the attribute of the directory  which the mdf file and ldf file were  laying on  has been set to readonly due to the database attach failed

    and then i removed the readonly attribute of the directory,and added everyone right to the directory

    after the setting, the attaching of database gone fine

    thanks

    • Proposed as answer by Donghui Li Monday, December 22, 2014 1:50 AM
    • Marked as answer by Donghui Li Friday, December 26, 2014 1:44 AM
    Friday, December 19, 2014 9:15 AM
  • Please change the locations of MDF and LDF and retry. And also make sure the required privileges to your account are in place.

    Regards, Pradyothana DP http://www.dbainhouse.blogspot.in/ Please Mark This As Answer if it solved your issue.

    • Marked as answer by Donghui Li Friday, December 26, 2014 1:44 AM
    Friday, December 19, 2014 10:34 AM