2010年12月22日 星期三

SQL Server: Getting User Session information

--Getting User Session information in SQL server 2005/2008
--In SQL server 2005/2008 if you want to check all SQL server sessions following is the command for viewing this;
select * from sys.dm_exec_sessions;
--But the above command will show the user sessions and as well as the system sessions, if you want to only see the user connections then following is the command;
select * from sys.dm_exec_connections;
--you can also get the session id from the below command and match it with the session_id column of the 2 or 1 command for viewing the specific session information.
Select @@SPID;
--OR
select * from master..sysprocesses
select * from sys.dm_exec_requests

沒有留言: