1. 程式人生 > >強制斷開sql server資料庫已有連線的方法

強制斷開sql server資料庫已有連線的方法

:: Disconnect existing Fortune database connections
osql -S"%1" -U"%2" -P"%3" -Q"declare @i int declare cur cursor for select spid from sysprocesses where db_name(dbid)= ' Your_Database_Name ' open cur fetch next from cur into @i while @@fetch_status=0 begin exec('kill '[email protected]) fetch next from cur into @i end close cur deallocate cur"