Introduction
In this article we will learn about the sp_who system Stored Procedure. The sp_who is an undocumented system Stored Procedure that is used to get the information of the current state of the SQL instance.
sp_who
The sp_who system Stored Procedure also allows fast monitoring of active and inactive processes. The sp_who is a system Stored Procedure gets information about all current adaptive server users and processes as well as getting information about a specific user or process.
Syntax
The syntax of the "sp_who" system Stored Procedure is as follows:
sp_who [usename][processid]
Where "username" is the name of the user to be queried and "processid" is the id of the process.
Example
Let's see an example.
We can get information about all processes and users currently being used using the following command:
Output
When we run the above command the output is as follows. It shows all the users being logged and databases being used.
Getting information about a specified user
We can get information about a specified user currently logged into the server using the following command:
Output
Getting information about a specified process
We can get information about a specified process currently being processed in the server using the following command: