Monitor sql connection from .Net SqlClient Data Provider

You can use the following sql script to monitor sql server processes and connections, whose function is almost the same as SP_Who &  SP_Who2.

Select spid, uid=RTrim(loginame), program_name=RTrim(program_name),
dbname
=db_name(dbid), status=RTrim(status) 
From master.dbo.sysprocesses
Where loginame='sa or other login name' and db_name(dbid)='database name' 
 
AND program_name='.Net SqlClient Data Provider'

eg.
Select spid, uid=RTrim(loginame), program_name=RTrim(program_name),
dbname
=db_name(dbid), status=RTrim(status) 
From master.dbo.sysprocesses
Where loginame='sa' and db_name(dbid)='HRIS2004' 
 
AND program_name='.Net SqlClient Data Provider'
posted @ 2004-06-28 23:55  Rickie  阅读(1665)  评论(0编辑  收藏  举报