error: during upgrade database raised exception 945 severity 14 state 2

  • I am getting this error after a detach re-attach to move the data and log files. I can not get the database out of read-only mode.

    alter database my db SET READ_WRITE

    Msg 5120, Level 16, State 101, Line 1

    Unable to open the physical file "E:\SQL_Data\Data\mydb.mdf". Operating system error 5: "5(Access is denied.)".

    Msg 5120, Level 16, State 101, Line 1

    Unable to open the physical file "E:\SQL_Data\Logs\mydb.ldf". Operating system error 5: "5(Access is denied.)".

    Msg 945, Level 14, State 2, Line 1

    Database 'mydb' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.

    Msg 5069, Level 16, State 1, Line 1

    ALTER DATABASE statement failed.

    Any suggestions...

  • My SQL Server service account has access to E:\SQL_Data.

  • I ended up restoring from backup which resolved the problem. Case closed. Thanks.

  • I had a similar problem after moving a database from D drive to E drive using detach and attach process. It turns out to be a permission issue on the target folder.

    After attaching the Database it was showing up as Read Only in Object Explorer.

    using the ALTER DATABASE <dbname> SET READ_WRITE was executing forever.

    To fix the problem and bring the database out of read_only state, I had to grant full control permissions

    on the folder containing the MDF and LDF files in drive E to the local security group

    SQLServerMSSQLUser$<machinename>$MSSQLSERVER

    This group should have the necessary permissions to write to the folder that you specified.

    After this step, the database was successfully set to Read_Write state.

  • OMG THANK YOU sailendra!

  • Thanks a lot. Assigning full control to SQL SErvice Account on respective file/folder works.:-)

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply