Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> Services >> DB >> SQLServer >> How to use sqlcmd.exe to obtain the number of open db connections to user databases

dbsession.bat ------------- sqlcmd -S <server-ip> -i dbsession.sql >> dbsession.out dsession.sql ------------ SET NOCOUNT ON; SELECT "Open DB sessions at : ", SYSDATETIME(); -- /////////////////////////////////////////////////////////////////////////// -- print '' -- print '---------------------------------------------------------------------------' -- print 'Active session count' -- print '---------------------------------------------------------------------------' -- /////////////////////////////////////////////////////////////////////////// DECLARE @temp TABLE(spid int , ecid int, status varchar(50), loginname varchar(50), hostname varchar(50), blk varchar(50), dbname varchar(50), cmd varchar(50), request_id int) INSERT INTO @temp EXEC sp_who SELECT dbname,loginname,COUNT(*) FROM @temp WHERE loginname <> 'sa' and dbname not in ( 'master','msdb') group by dbname,loginname
[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]