Monday, June 16, 2014

Query sp_Who2

sp_Who by MSDN - "Provides information about current users, sessions, and processes in an instance of the Microsoft SQL Server Database Engine. The information can be filtered to return only those processes that are not idle, that belong to a specific user, or that belong to a specific session."

DECLARE @Table TABLE( SPID smallint, Status nchar(30), LOGIN nchar(128), HostName nchar(128), BlkBy char(5), DBName nchar(128), Command nchar(16), CPUTime INT, DiskIO INT, LastBatch VARCHAR(MAX), ProgramName VARCHAR(MAX), SPID_1 INT, REQUESTID INT ) INSERT INTO @Table EXEC sp_who2 SELECT * FROM @Table WHERE DBName = 'DB_NAME'

Share/Bookmark

No comments: