sp_dboption 'dbname','offline','true'sp_dboption 'dbname','offline','false' 我都试了100遍了,出错: Server: Msg 5160, Level 16, State 1, Line 0 Cannot take 'Era' offline because the database is in use.
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 '数据库名'
我都试了100遍了,出错:
Server: Msg 5160, Level 16, State 1, Line 0
Cannot take 'Era' offline because the database is in use.
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 '数据库名'
"写入名字"-->不要与现在的冲突了,或选强制恢复
"改为现在的data目录的路径"-->如默认是"c:\....data\....mdf"而你现在的sql的data目录是d:\....data你就改为d:\...data\...mdf
还有我是用VC程序呀,不是用工具,有没有搞错!!没你分
而且,什么SQL7,什么VC,你也没说清楚啊!