TSQL - Get All Queries Currently Running

ben himself's picture

This is perhaps my most commonly used query when troubleshooting.

From SQL Server DMV's in action ebook. The output shows the spid (process identifier), the ecid (this is similar to a thread within the same spid and is useful for identifying queries running in parallel), the database name, the user running the SQL, the status (whether the SQL is running or waiting), the wait status (why it’s waiting), the hostname, the domain name, and the start time (useful for determining how long the batch has been running). If there is significant CPU usage but you cannot track down which SPID is doing it, OR if this query returns no results but something is definitely going on, see: https://gist.github.com/benf101/185cb4cbd68c15015dc7a59d37059e11

One of the most useful things to know when troubleshooting is what is running right now.

Also, Try These sp_who2 Alternatives

sp_who2 alternative

sp_who2 alternative with query text

Tags: 

Categories: