user lst

Hello,

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

thank you
RayneAsked:
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
go
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).
0
 
RayneAuthor Commented:
pull list of all users in a server...basically
0
 
dannygonzalez09Connect With a Mentor Commented:
You can use Exec sp_who to get the list of all active connections
0
 
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
0
 
RayneAuthor Commented:
thank you all :)
0
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.