login names from sp_who2

Hi,

How do we find out the login names from the o/p of sp_who2 when there are multiple queries are being exe

September 9th, 2015 2:05pm

I am not exeactly sure what you are asking, loginname is part of the output of sp_who2.

If you are looking for only distinct loginnames from sp_who2 you can store the output of sp_who2 into a temp table and them do a select distinct loginname from <temptable>

If you are on SQL2005 and newer ( which i hope you are) you can also just use DMV to get the same information you are looking for, something like this:

select distinct s.login_name
from sys.dm_exec_requests r
join sys.dm_Exec_sessions s on r.session_id = s.session_id
where r.session_id>50

Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 5:00pm

Hi Arun,

When you issue sp_who2 the result will display the log in information.

In here login means the user established connection with the database.

This log in establishes connection between database and application.

i hope this helps.

thanks

kumar

September 9th, 2015 7:43pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics