user lst


Is there is tsql query or anything to pull the list of active user in a sql server?

thank you
Who is Participating?
Steve WalesConnect With a Mentor Senior Database AdministratorCommented:
Not sure if you're after active sessions, or actual list of logins on the server.

To get the list of logins from your server:

use master
select * from sys.server_principals where type in ('S','G','U');

Open in new window

(This is what you see if you expand Security / Logins from SSMS Object Explorer).
RayneAuthor Commented:
pull list of all users in a server...basically
dannygonzalez09Connect With a Mentor Commented:
You can use Exec sp_who to get the list of all active connections
dannygonzalez09Connect With a Mentor Commented:
You can use the below query to get the list of active users per database

SELECT DB_NAME(dbid) as 'Database', COUNT(dbid) as nnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame
RayneAuthor Commented:
thank you all :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.