create proc sp_killuser
@username sysname=null
as
declare tb cursor local
for
select 'kill '+rtrim(spid) from master.dbo.sysprocesses
where loginame=isnull(@username,suser_sname())
and spid>=50
and hostname<>host_name()
declare @s nvarchar(1000)
open tb
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
go
declare tb cursor local
for
select 'kill '+rtrim(spid) from master.dbo.sysprocesses
where loginame=suser_sname()
and spid>=50
and hostname<>host_name()
declare @s nvarchar(1000)
open tb
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb