After looking around, I found a snippet in this forum. I only flushed out the declares, the bulk of the code is from the person who posted the code. Thanks everyone for your help!
USE Master
go
DECLARE
@nKillProcess as varchar(50),
@nFetchStatus as varchar(50),
@sTemp as varchar(50)
DECLARE curProcesses CURSOR
LOCAL
FAST_FORWARD
READ_ONLY
FOR
SELECT spid
FROM
Master..sysprocesses
WHERE
dbid = 5 -- 5 = Vet, 6 = SAA
OPEN curProcesses
FETCH NEXT FROM curProcesses INTO --Gets the first process
@nKillProcess
SET @nFetchStatus = @@FETCH_STATUS
--Kill the processes
WHILE @nFetchStatus = 0
BEGIN
SET @sTemp ='KILL ' + CAST(@nKillProcess as varchar(5))
EXEC(@sTemp)
FETCH NEXT FROM curProcesses INTO --Gets the next process
@nKillProcess
SET @nFetchStatus = @@FETCH_STATUS
END
CLOSE curProcesses
DEALLOCATE curProcesses