等了好久,總算等到台灣開賣了,當然要趁聖誕節買一個來玩玩看囉!!
戴在手上其實很輕,沒有什麼感覺,可能要小心的就是不小心擠壓到彈飛出去吧XD
DECLARE @spid int, @SQLstr nvarchar(128) DECLARE spids_cr CURSOR FOR SELECT p.spid FROM sys.sysprocesses P JOIN sys.sysdatabases D ON (D.dbid = P.dbid) JOIN sys.sysusers U ON (P.uid = U.uid) WHERE hostname != '' AND hostname = @hostname AND [P].[program_name]='.Net SqlClient Data Provider ' FOR READ ONLY OPEN spids_cr FETCH spids_cr INTO @spid WHILE (@@FETCH_STATUS=0) BEGIN SET @SQLstr = 'KILL ' + CAST(@spid AS varchar) EXEC sp_executesql @SQLstr FETCH spids_cr INTO @spid END CLOSE spids_cr DEALLOCATE spids_cr參考:http://www.stev.org/post/2011/03/01/MS-SQL-Kill-connections-by-host.aspx http://sharedderrick.blogspot.tw/2008/01/kill-all-connection.html