I used a modifed version to block users from my database. Instead of using a cursor you can use...
declare @out nVarchar(4000)
SELECT @out = COALESCE (RTRIM(@out)+' Kill ' ,'')+ cast(spid as varchar(10))
from master..sysprocesses where db_name(dbid) = 'myDatabase' AND NT_USERNAME like @uid
set @out= 'kill ' + @out
execute sp_executesql @out