SQL Server 2008 R2 Stuck in Single User Mode

后端 未结 5 2015
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 10:24

Having executed a DB deploy (from a VS SQL Server database project) on a local database, which failed, the database has been left in a state where it has single user mode left o

相关标签:
5条回答
  • 2021-01-30 11:01

    This was answered here, the code is:

    use master
    ALTER DATABASE YourDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE 
    
    --do you stuff here 
    
    ALTER DATABASE YourDatabase SET MULTI_USER
    
    0 讨论(0)
  • 2021-01-30 11:09

    To force the update use " with rollback immediate"

    ALTER DATABASE [DATABASE_NAME] SET MULTI_USER  with rollback immediate
    
    0 讨论(0)
  • 2021-01-30 11:18

    In first run following query in master database

    exec sp_who
    

    If you can't find the culprit, try

    SELECT request_session_id FROM sys.dm_tran_locks 
    WHERE resource_database_id = DB_ID('YourDatabase')
    

    Then kill all process that use your database with following query:

    KILL spid
    

    Then run following query:

    USE Master
    ALTER DATABASE YourDatabase SET MULTI_USER
    
    0 讨论(0)
  • 2021-01-30 11:22

    Try the below commands

    First run these three commands

    USE [master] 
    SET DEADLOCK_PRIORITY HIGH
    exec sp_dboption MyDBName, 'single user', 'FALSE';
    

    Second run these two commands

    ALTER DATABASE MyDBName SET MULTI_USER WITH NO_WAIT
    ALTER DATABASE MyDBName SET MULTI_USER WITH ROLLBACK IMMEDIATE
    
    0 讨论(0)
  • 2021-01-30 11:25

    Use DAC (Dedicated Admin Connection). Make sure you have enabled it first In SSMS type in admin: for Server Name after connecting to master ALTER DATABASE SET MULTI_USER

    0 讨论(0)
提交回复
热议问题