怎样定时删除sql server中的睡眠进程?

haitao5676 2004-12-14 10:14:09
请问各位大虾,如何能够定时删除这些sleeping的进程
...全文
161 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
haitao5676 2004-12-14
  • 打赏
  • 举报
回复
知道了,实在是太感谢了
100分送给你
txlicenhe 2004-12-14
  • 打赏
  • 举报
回复

use master
go
create proc killid
as
begin
declare @sql nvarchar(500),@temp varchar(1000)
declare @spid int
set @sql='declare getspid cursor for
select spid from sysprocesses where lastwaittype = ''sleep'''
exec (@sql)
open getspid
fetch next from getspid into @spid
while @@fetch_status =0
begin
set @temp='kill '+rtrim(@spid)
exec(@temp)
fetch next from getspid into @spid
end
close getspid
deallocate getspid
end
haitao5676 2004-12-14
  • 打赏
  • 举报
回复
主要是job里的具体脚本?
我要定时的删除sleeping进程,不能直接kill所有进程呀!
haitao5676 2004-12-14
  • 打赏
  • 举报
回复
具体方法呢?
谢谢你,说全点吧!
txlicenhe 2004-12-14
  • 打赏
  • 举报
回复
用job

27,580

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧