Monday, July 9, 2012

Information about current users, sessions and processes

PROBLEM:
You need information about current users, sessions, and processes in an instance of the Microsoft SQL Server Database Engine. You want to filtered it to return only those processes that are not idle, that belong to a specific user, or that belong to a specific session

SOLUTION:
Listing all current processes
USE master;
GO
EXEC sp_who2
GO

Listing a specific user's process
USE master;
GO
EXEC sp_who2 'domain\joe'
GO

Displaying all active processes
USE master;
GO
EXEC sp_who2 'active'
GO

Displaying a specific process identified by a session ID
USE master;
GO
EXEC sp_who2 '10' --specifies the process_id
GO

If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!

No comments:

Post a Comment