ALTER DATABASE Issue

  • genadyd

    SSC Enthusiast

    Points: 190

    Hello,

    I faced  very strange issue.

    When I try from management studio to put the specific database to RESTRICTED_MODE, the operation succeeded,

    but when I try to do it from the operation script, I receive a message :

    "Msg 5070, Level 16, State 2, Line 3

    Database state cannot be changed while other users are using the database 'MyDBName'

    Msg 5069, Level 16, State 1, Line 3

    ALTER DATABASE statement failed."

    Thank you.

     

    • This topic was modified 1 month, 2 weeks ago by  genadyd.
  • Ken McKelvey

    SSCoach

    Points: 18319

    Make sure your default db is not MyDBName and use:

    WITH ROLLBACK IMMEDIATE

  • flouage

    Newbie

    Points: 2

    many times it is due to the fact that your query is running against the MyDBName database and so there is an open connection.

    Frank

  • genadyd

    SSC Enthusiast

    Points: 190

    flouage, thank you, I'll try.

  • genadyd

    SSC Enthusiast

    Points: 190

    Hi,

    WITH ROLLBACK IMMEDIATE option did not helped me.

    But your suggestion about "default db is not MyDBName", I will try it.

    Thanks.

     

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

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