博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关闭进程的--数据库
阅读量:7156 次
发布时间:2019-06-29

本文共 652 字,大约阅读时间需要 2 分钟。

use  master

go
 
if  exists  (select  *  from  dbo.sysobjects  where  id  =  object_id(N'[dbo].[p_killspid]')  and  OBJECTPROPERTY(id,  N'IsProcedure')  =  1)
drop  procedure  [dbo].[p_killspid]
GO
 
create  proc  p_killspid
@dbname  varchar(200) --要关闭进程的数据库名
as     
declare  @sql    nvarchar(500)     
declare  @spid  nvarchar(20)
 
declare  #tb  cursor  for
select  spid=cast(spid  as  varchar(20))  from  master..sysprocesses  where  dbid=db_id(@dbname)
open  #tb
fetch  next  from  #tb  into  @spid
while  @@fetch_status=0
begin     
exec('kill  '+@spid)
fetch  next  from  #tb  into  @spid
end     
close  #tb
deallocate  #tb
go
 
--用法     
exec  p_killspid    'shcdf'

转载于:https://www.cnblogs.com/wlwjc/archive/2013/03/10/2952677.html

你可能感兴趣的文章
将Cent0S 7的网卡名称eno16777736改为eth0
查看>>
支付宝pc端支付接入PHP实现
查看>>
writing-mode改变文字书写方式
查看>>
怎样当好一个师长
查看>>
Web Server 与 App Server
查看>>
找出包含正好5个字符的名字
查看>>
[译]Godot系列教程五 - 制作Godot编辑器插件
查看>>
WebSocket实战之————Workerman服务器的安装启动
查看>>
java-pageEncoding与contentType的区别
查看>>
线程池调优
查看>>
直接插入排序
查看>>
Java高级特性之泛型
查看>>
squirrelsql安装
查看>>
@validated 验证 List 参数在spring中
查看>>
Tire树
查看>>
how to install oracle jdk 7 on ubuntu lucid lts 10.04
查看>>
install 7z support for ubuntu
查看>>
利用kettle中的JS来完成ETL数据校验
查看>>
Python自然语言处理学习笔记(18):3.2 字符串:最底层的文本处理
查看>>
quartz和spring结合后的使用,模仿型
查看>>