Having Trouble Deleting a DB

  • djustice 20821 (3/27/2012)


    This is the code that I used:

    ALTER DATABASE DB

    SET SINGLE_USER

    WITH ROLLBACK IMMEDIATE

    GO

    DROP DATABASE db

    GO

    and the error that I got:

    Msg 5064, Level 16, State 1, Line 1

    Changes to the state or options of database 'readydesk' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.

    You can't drop a database that you are connected to. That could be the issue. You would have to change the connection to MASTER.

    Jared
    CE - Microsoft

  • I actually tried that. After the above didn't work, I shut down SQL, logged back in and used the code:

    USE MASTER

    GO

    DROP DATABASE db

    GO

    Received the same error about the DB is being used? The KILL process was a last resort.

  • Again, the point being that as soon as you logged off of SQL Server, something created a connection. You should have found out what that was...

    Jared
    CE - Microsoft

  • Gotcha, too late now, but I'll remember it for next time. Thanks again for your help.

Viewing 4 posts - 16 through 20 (of 20 total)

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