use master
declare @dbname varchar(50)
set @dbname='数据库名'
declare @sql varchar(50)
declare cs_result cursor local for
select 'kill '+cast(spid as varchar(50)) from master.sys.sysprocesses where db_name(dbid)=@dbname
open cs_result
fetch next from cs_result into @sql
while @@fetch_status=0
begin
execute(@sql)
fetch next from cs_result into @sql
end
close cs_result
deallocate cs_result