我试图恢复我的sql使用bak文件
我收到错误
我试过了
USE [master] ALTER DATABASE myDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;@H_403_9@并运行查询
USE [master] RESTORE DATABASE myDB FROM DISK = 'C:\MyDatabase.bak' WITH FILE = 1,NOUNLOAD,STATS = 10@H_403_9@我也从恢复向导尝试了相同的结果.
解决方法
方法1
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...'@H_403_9@方法2
alter database database_name set offline with rollback immediate alter database database_name set online@H_403_9@走