还原sql server数据库时,无法获得对数据库的独占访问权
declare @dbname?? varchar(20)
set @dbname='56fc'
declare?? @sql?? nvarchar(500)
declare?? @spid?? int--SPID?? 值是當用戶進行連接時指派給該連接的一個唯一的整數
set?? @sql= 'declare?? getspid?? cursor?? for?? select?? spid?? from?? sysprocesses?? where?? dbid=db_id('''+@dbname+''') '
--sysprocesses?? 包含有關?? SQL?? Server?? 進程的信息。
exec?? (@sql)
open?? getspid
fetch?? next?? from?? getspid?? into?? @spid
while?? @@fetch_status <> -1--如果FETCH?? 語句沒有執行失敗或此行不在結果集中。
begin
exec( 'kill?? '+@spid)--終止正常連接
fetch?? next?? from?? getspid?? into?? @spid
end
close?? getspid
deallocate?? getspid
轉載于:https://www.cnblogs.com/qindgfly/archive/2010/08/31/1813633.html
總結
以上是生活随笔為你收集整理的还原sql server数据库时,无法获得对数据库的独占访问权的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Sun JDK: Hashmap.get
- 下一篇: 出现authentication mod