ExpungeUsers_bwunder_Pubs

ExpungeUsers_bwunder_Pubs is a sample of a spid killer generated by the MakeSPidKiller stored procedure.
create procedure ExpungeUsers_bwunder_Pubs
   as
   declare @spid int
   declare @cmd varchar(100)
   declare dbuserscursor cursor
   for
   select spid 
   from bwunder.master.dbo.sysprocesses p 
   inner join bwunder.master.dbo.sysdatabases d 
   on p.dbid = d.dbid
   where d.name like 'Pubs'

   set nocount on

   open dbuserscursor
   fetch next from dbuserscursor into @spid
   while (@@fetch_status = 0) begin
      set @cmd = 'osql -Usa -E -S bwunder -dmaster -Q"kill ' 
                 + cast(@spid as varchar(5)) + '"'
      exec master.dbo.xp_cmdshell @cmd, no_output
      fetch next from dbuserscursor into @spid
   end
   close dbuserscursor
   deallocate dbuserscursor

   if (select count(spid) 
       from bwunder.master.dbo.sysprocesses p 
       inner join bwunder.master.dbo.sysdatabases d 
       on p.dbid = d.dbid
       where d.name like 'Pubs') = 0
      return
   else 
      return 1