我想分离数据库,在企业管理器中选择分离数据库,数据库的状态显示使用本数据库的连接有4个,选用清除后,数据库的状态显示使用本数据库的连接有0个,然后再选择分离数据库,这时就出错了显示无法分离数据库,因为该数据库正在使用。
我就用以下的存储过程清除:
declare @sql nvarchar(500)
declare @spid int
declare getspid cursor for select spid from sysprocesses where dbid=db_id('hsdb_xx')
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
停止数据库等方法都不能清除数据库正在使用状态。而数据库确实没有人在使用
我就用以下的存储过程清除:
declare @sql nvarchar(500)
declare @spid int
declare getspid cursor for select spid from sysprocesses where dbid=db_id('hsdb_xx')
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
停止数据库等方法都不能清除数据库正在使用状态。而数据库确实没有人在使用
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货