ALTER DATABASE failed because a lock could not be placed on database

后端 未结 10 2262
感情败类
感情败类 2020-12-12 09:52

I need to restart a database because some processes are not working. My plan is to take it offline and back online again.

I am trying to do this in Sql Server Manage

10条回答
  •  自闭症患者
    2020-12-12 10:27

    I managed to reproduce this error by doing the following.

    Connection 1 (leave running for a couple of minutes)

    CREATE DATABASE TESTING123
    GO
    
    USE TESTING123;
    
    SELECT NEWID() AS X INTO FOO
    FROM sys.objects s1,sys.objects s2,sys.objects s3,sys.objects s4 ,sys.objects s5 ,sys.objects s6
    

    Connections 2 and 3

    set lock_timeout 5;
    
    ALTER DATABASE TESTING123 SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
    

提交回复
热议问题