我试图恢复我的sql使用bak文件
我收到错误
我试过了
@H_403_8@USE [master] ALTER DATABASE myDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;并运行查询
@H_403_8@USE [master] RESTORE DATABASE myDB FROM DISK = 'C:\MyDatabase.bak' WITH FILE = 1,NOUNLOAD,STATS = 10我也从恢复向导尝试了相同的结果.
解决方法
方法1
@H_403_8@declare @sql as varchar(20),@spid as int
select @spid = min(spid) from master..sysprocesses where dbid = db_id('<database_name>') and spid != @@spid
while (@spid is not null)
begin
print 'Killing process ' + cast(@spid as varchar) + ' ...'
set @sql = 'kill ' + cast(@spid as varchar)
exec (@sql)
select
@spid = min(spid)
from
master..sysprocesses
where
dbid = db_id('<database_name>')
and spid != @@spid
end
print 'Process completed...'
方法2
@H_403_8@alter database database_name set offline with rollback immediate alter database database_name set online走