Chinaunix首页 | 论坛 | 博客
  • 博客访问: 553985
  • 博文数量: 298
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 3077
  • 用 户 组: 普通用户
  • 注册时间: 2019-06-17 10:57
文章分类

全部博文(298)

文章存档

2022年(96)

2021年(201)

2019年(1)

我的朋友

分类: SQLServer

2022-02-07 11:41:45


点击(此处)折叠或打开



  1. 存储过程必须要创建在系统数据库的master里
  2. #from fhadmin.cn
  3. create proc killspid (@dbname varchar(20))
  4. as
  5. begin
  6. declare @sql nvarchar(500)
  7. declare @spid int
  8. set @sql='declare getspid cursor for select spid from sysprocesses where dbid=db_id('''+@dbname+''')'
  9. exec (@sql)
  10. open getspid
  11. fetch next from getspid into @spid
  12. while @@fetch_status <> -1
  13. begin
  14. exec('kill '+@spid)
  15. fetch next from getspid into @spid
  16. end
  17. close getspid
  18. deallocate getspid
  19. end


阅读(457) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~