Sp_who Stored Procedure in SQL Server 2012

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:

sp_who-command-in-SQL.jpg

Output

When we run the above command the output is as follows. It shows all the users being logged and databases being used.

result-sp_who-command-in-SQL.jpg

Getting information about a specified user

We can get information about a specified user currently logged into the server using the following command:

particular-sp_who-command-in-SQL.jpg

Output

result-particular-sp_who-command-in-SQL.jpg

Getting information about a specified process

We can get information about a specified process currently being processed in the server using the following command:

particular2-sp_who-command-in-SQL.jpg

Up Next
    Ebook Download
    View all
    Learn
    View all