Wednesday, June 25, 2014

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'


No comments:

Post a Comment