Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Express 2005 Database Read-Only Problem

SQL Express 2005 Database Read-Only Problem

Scheduled Pinned Locked Moved Database
databasehelpsharepointsql-serversysadmin
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ahmad Safwat
    wrote on last edited by
    #1

    Hi, I have a problem with attaching databases to Microsoft SQL Server Express 2005, databases are attached as Read-Only even I'm using Management Studio or sp_attach_db stored procedure. Can you help me??

    W P 2 Replies Last reply
    0
    • A Ahmad Safwat

      Hi, I have a problem with attaching databases to Microsoft SQL Server Express 2005, databases are attached as Read-Only even I'm using Management Studio or sp_attach_db stored procedure. Can you help me??

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      One possibility is that the database is marked read-only before detach. If the database isn't in restoring state (everything is fine after attach), could you simply set it to read-write state:

      ALTER DATABASE DatabaseName SET READ_WRITE;

      The need to optimize rises from a bad design. My articles[^]

      A 1 Reply Last reply
      0
      • W Wendelius

        One possibility is that the database is marked read-only before detach. If the database isn't in restoring state (everything is fine after attach), could you simply set it to read-write state:

        ALTER DATABASE DatabaseName SET READ_WRITE;

        The need to optimize rises from a bad design. My articles[^]

        A Offline
        A Offline
        Ahmad Safwat
        wrote on last edited by
        #3

        Hi Mika, thanx for reply I cannot change database to be read write when I tried your code I received the following errors:

        Msg 5120, Level 16, State 101, Line 1
        Unable to open the physical file "D:\>> DatabaseName.mdf". Operating system error 5: "5(error not found)".

        Msg 5120, Level 16, State 101, Line 1
        Unable to open the physical file "D:\>> DatabaseName.ldf". Operating system error 5: "5(error not found)".

        File activation failure. The physical file name ">> DatabaseName.ldf" may be incorrect.

        Msg 945, Level 14, State 2, Line 1
        Database 'DatabaseName' 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.

        My database is a valid database copied from another machine on witch it works fine.

        W 1 Reply Last reply
        0
        • A Ahmad Safwat

          Hi, I have a problem with attaching databases to Microsoft SQL Server Express 2005, databases are attached as Read-Only even I'm using Management Studio or sp_attach_db stored procedure. Can you help me??

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Is the database file's attribute set to readonly?

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

          1 Reply Last reply
          0
          • A Ahmad Safwat

            Hi Mika, thanx for reply I cannot change database to be read write when I tried your code I received the following errors:

            Msg 5120, Level 16, State 101, Line 1
            Unable to open the physical file "D:\>> DatabaseName.mdf". Operating system error 5: "5(error not found)".

            Msg 5120, Level 16, State 101, Line 1
            Unable to open the physical file "D:\>> DatabaseName.ldf". Operating system error 5: "5(error not found)".

            File activation failure. The physical file name ">> DatabaseName.ldf" may be incorrect.

            Msg 945, Level 14, State 2, Line 1
            Database 'DatabaseName' 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.

            My database is a valid database copied from another machine on witch it works fine.

            W Offline
            W Offline
            Wendelius
            wrote on last edited by
            #5

            Ahmad Safwat wrote:

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

            In the ALTER command, replace the DatabaseName with the actual database name and try again. Now you tried to set options for database named DatabaseName. For example if your database is named Test then the command would be:

            ALTER DATABASE Test SET READ_WRITE;

            The need to optimize rises from a bad design. My articles[^]

            A 1 Reply Last reply
            0
            • W Wendelius

              Ahmad Safwat wrote:

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

              In the ALTER command, replace the DatabaseName with the actual database name and try again. Now you tried to set options for database named DatabaseName. For example if your database is named Test then the command would be:

              ALTER DATABASE Test SET READ_WRITE;

              The need to optimize rises from a bad design. My articles[^]

              A Offline
              A Offline
              Ahmad Safwat
              wrote on last edited by
              #6

              I'm sorry it was the weak end, and I was unable to follow up the thread

              Mika Wendelius wrote:

              replace the DatabaseName with the actual database name

              I understood you first time and this is what I exactly did, and received the previous errors. And my database is a valid database copied from another machine on witch it works fine.

              W 1 Reply Last reply
              0
              • A Ahmad Safwat

                I'm sorry it was the weak end, and I was unable to follow up the thread

                Mika Wendelius wrote:

                replace the DatabaseName with the actual database name

                I understood you first time and this is what I exactly did, and received the previous errors. And my database is a valid database copied from another machine on witch it works fine.

                W Offline
                W Offline
                Wendelius
                wrote on last edited by
                #7

                Ok, The error message you got when trying to set read_write is quite odd. It clearly states that your physical files are not in good condition or not found. - are there any suspicious messages in the error log when you attach the database? - also check that the file attributes are correct on both physical files (not read-only and not system)

                The need to optimize rises from a bad design. My articles[^]

                A 1 Reply Last reply
                0
                • W Wendelius

                  Ok, The error message you got when trying to set read_write is quite odd. It clearly states that your physical files are not in good condition or not found. - are there any suspicious messages in the error log when you attach the database? - also check that the file attributes are correct on both physical files (not read-only and not system)

                  The need to optimize rises from a bad design. My articles[^]

                  A Offline
                  A Offline
                  Ahmad Safwat
                  wrote on last edited by
                  #8

                  !!! S U R P R I S E !!! The problem has been solved by changing "Log On" type of SQL Server Service from "Network Service" to "Local System". Now, I changed "Log On" type back to "Network Service" and still no problem !!! Can anybody explain that to me??

                  W 1 Reply Last reply
                  0
                  • A Ahmad Safwat

                    !!! S U R P R I S E !!! The problem has been solved by changing "Log On" type of SQL Server Service from "Network Service" to "Local System". Now, I changed "Log On" type back to "Network Service" and still no problem !!! Can anybody explain that to me??

                    W Offline
                    W Offline
                    Wendelius
                    wrote on last edited by
                    #9

                    Local system has all the privileges for the computer whereas privileges for Network Service are limited. There are several reasons to this. Your datafiles in the db you attached may have had restrictions at file level which are now corrected, the directory where the files reside may have had a privilege problem etc. Didn't the errorlog say anything when you attached the database for the first time?

                    The need to optimize rises from a bad design. My articles[^]

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups