In a technical sense of course 🙂
Here’s the code – very handy before a restore …
DECLARE processes CURSOR FOR
select spid from sysprocesses where dbid=(select dbid from sysdatabases where name='AdventureWorks') and status in ('runnable','sleeping')
DECLARE @processid int -- spid of active processes
OPEN processes --open the cursor
FETCH FROM processes INTO @processid
WHILE (@@FETCH_STATUS = 0)
--cycle through the list and kill each spid
BEGIN
Print @processid
Print 'killed'
Exec ('
kill '+@processid+'
')
FETCH FROM processes INTO @processid
END -- END OF WHILE (@@FETCH_STATUS = 0)
CLOSE processes
DEALLOCATE processes