1、使用SQL 賬號登錄並進行還原時會出現以上錯誤提示,轉用windows登錄即可正常還原數據庫;
2、如果是使用查詢分析器還原,請參考:
restore database Auction from disk='path' with replace;
System.Data.SqlClient.SqlException: RESTORE 無法處理數據庫 'Auction',因為它正由此會話使用。建議在執行此操作時使用 master 數據庫。 RESTORE DATABASE 正在異常終止。
很明顯的錯誤提示了,語句改成
use master; restore database Auction from disk='path' with replace;
3、轉自網絡:
當還原ms sql server 數據庫出現如下錯誤:
無法處理數據庫 'XXXXX',因為它正由此會話使用。建議在執行此操作時使用 master 數據庫。
可用如下命令去還原
use master
declare @s varchar(8000)
select @s=isnull(@s,'')+' kill '+rtrim(spID) from master..sysprocesses where dbid=db_id('數據庫名稱')
select @s
exec(@s)
RESTORE DATABASE 數據庫名稱
FROM DISK = N'還原數據庫備份的文件路徑.bak'
with replace
