How to find out the users logged in to a SQL Server 2005 database

In order to find out the users logged in to a database, use the system view called sys.sysprocesses.

select * from sys.sysprocesses

returns you a host of information about the login name, Windows user name, processes running on an instance of SQL Server etc.. Check out the hostname, nt_username, loginame, nt_domain columns returned on executing the above query.

Read more about sys.sysprocesses over here

http://msdn2.microsoft.com/en-us/library/ms179881.aspx

You can also try out the stored procedures sp_who

EXEC sp_who

EXEC sp_who2

sp_who provides information about current users, sessions, and processes in an instance of SQL Server

No comments:

Post a Comment