Return to Snippet

Revision: 60068
at October 19, 2012 03:34 by derebus

Initial Code

SELECT @SQL=COALESCE(@SQL,'')+'Kill '+CAST(spid AS VARCHAR(10))+ '; '  
FROM sys.sysprocesses  
WHERE DBID=DB_ID('AdventureWorks') 

PRINT @SQL --EXEC(@SQL) Replace the print statement with exec to execute

Initial URL

Initial Description
If you have ever tried to restore a database and could not obtain exclusive access, you know how useful this can be.

Initial Title
kill all the transactions in a database

Initial Tags

Initial Language