DECLARE @SQL VARCHAR(8000)
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
Friday, June 20, 2008
Kill all users in a Database
Here is a cool little script that will kill all spids in a specified database.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment