sql server2000
在数据库中由于log文件过大,想要执行detach该数据库,但是由于有人连接该数据库,在clear之后,点ok提示错误3701
error3701,can not detach the database because is currently in used
可是应该已经没有人在使用了,请各位大虾指教!!!!
...全文
1814打赏收藏
无法detach掉的数据库
sql server2000 在数据库中由于log文件过大,想要执行detach该数据库,但是由于有人连接该数据库,在clear之后,点ok提示错误3701 error3701,can not detach the database because is currently in used 可是应该已经没有人在使用了,请各位大虾指教!!!!
大力的:
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
declare @a varchar(100)
while @@fetch_status < >-1
begin
set @a='kill '+rtrim(@spid)
exec(@a)
fetch next from getspid into @spid
end
close getspid
deallocate getspid
end