Posted on Leave a comment

SQL Server 2012: Kill all processes for a specific database


          SELECT 'KILL ' + cast(A.session_id as varchar)
            FROM sys.dm_exec_sessions A WITH (NOLOCK)
      INNER JOIN sys.databases B WITH (NOLOCK)
              ON A.database_id = B.database_id
           WHERE B.name = 'your.dbname.here'


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.