Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

usp_SQL_In_sp_who2

By Banyardi Schmardi,

Like most DBAs I frequently use sp_who2 to monitor activity at any given moment. Many times however I would identify a SPID that had a high CPU utilization or came from an unkown host and I would wish that I could see the SQL running under that SPID without having to fire up SQL Profiler.

I finally did some research and found that the DBCC INPUTBUFFER(SPID) would return what I was looking for. The input buffer doesn't always contain SQL, but for the SPIDs I have questions about it usually does. I coded a stored procedure, usp_SQL_In_sp_who2, to include the contents of the Input buffer and the length of the input buffer which I find useful in identifying at-a-glance monster queries.

Brandon Forest
SQL Server DBA

Total article views: 1186 | Views in the last 30 days: 1
 
Related Articles
BLOG

PowerShell-Input-Validation Scripts

Input values are validated using various mechanisms.  let’s start by examining how you would validat...

BLOG

PowerShell-Input-Validation Scripts

Input values are validated using various mechanisms.  let’s start by examining how you would validat...

FORUM

Buffer Latch Time out

SQL dump indicates there was a buffer latch timout.

FORUM

Buffer Cache

Buffer Cache

FORUM

Sport Lap time Input

Inputting sport times

Tags
input buffer    
sp_who2    
spid    
 
Contribute