sql server 强制删除连接
2012-09-12 15:39
190 查看
用SQl语句控制MS SQl server的用户连接
if exists(select 1 from sysobjects where name = 'killspid' and type = 'P')
drop proc killspid
create proc killspid (@dbname varchar(20))
as
begin
declare @sql nvarchar(500)
declare @spid int
set @sql='declare getspid cursor for
select spid from sysprocesses where dbid=db_id('''+@dbname+''')'
exec (@sql)
open getspid
fetch next from getspid into @spid
while @@fetch_status < >-1
begin
exec('kill '+@spid)
fetch next from getspid into @spid
end
close getspid
deallocate getspid
end
--用法
use master
exec killspid '数据库名'
if exists(select 1 from sysobjects where name = 'killspid' and type = 'P')
drop proc killspid
create proc killspid (@dbname varchar(20))
as
begin
declare @sql nvarchar(500)
declare @spid int
set @sql='declare getspid cursor for
select spid from sysprocesses where dbid=db_id('''+@dbname+''')'
exec (@sql)
open getspid
fetch next from getspid into @spid
while @@fetch_status < >-1
begin
exec('kill '+@spid)
fetch next from getspid into @spid
end
close getspid
deallocate getspid
end
--用法
use master
exec killspid '数据库名'
相关文章推荐
- sql server 强制删除连接
- Sql Server 强制断开数据库已有连接的方法
- 在sql server里连接远程服务器,并进行创建和删除新数据库
- 收藏 不显示删除回复显示所有回复显示星级回复显示得分回复 用户 '' 登录失败。该用户与可信 SQL Server 连接无关联
- 强制删除正在连接的Oracle用户,以删除SDE用户为例
- 强制删除正在连接的Oracle用户,以删除SDE用户为例
- SQL Server强制删除复制发布
- SQL Server中强制关闭数据库连接
- 删除所有sql server连接
- SQL Server强制删除复制发布
- GridView连接SQL Server 2005实现增加、更新、删除按钮时遇到的两个错误及解决办法
- SQL Server中强制关闭数据库连接
- 强制删除正在连接的Oracle用户,以删除SDE用户为例
- 强制SQL SERVER使用某种表连接方式
- 强制删除正在连接的Oracle用户,以删除SDE用户为例
- 强制删除正在连接的Oracle用户,以删除SDE用户为例
- SQL Server中强制关闭数据库连接
- Oracle:强制删除正在连接的用户
- SQL Server 表连接删除
- 在sql server里连接远程服务器,并进行创建和删除新数据库