Following the series "SQL Swiss Army Knife", here is another version of this script that I’ve been using and tweaking for years now. This way I can get a quick overview of query execution on a given SQL Server instance, from SQL Server 2005 up to SQL Server 2016.
The first section will report on all requests. In here there is info on running batches, the statement in the batch that is currently running and its status. Also, there is information about the cached query plan, current I/O, CPU and time stats, the current wait type, resource (if any) and other useful data.
The output will look something like below, and you can get further detail on statements and plans by clicking on the XML links:
The second section is the Waiter and Blocking Report, where we find the queries that are blocked, such as the spid, its wait type, resource and time. Still on the blocked query, the associated batch, blocking elapsed time and database name. On the blockers, there is information on the spid, if it is the head blocker in a given blocking chain and what is the blocker batch. Additional information on the involved hosts and programs is also available.
As before, you can get further detail by clicking on the XML links:
And last, starting with SQL Server 2012, you can get some details on Stored Procedures execution statistics from the
DMV, like below:
That’s it for now, hope you find it useful.
Until next time!
Added page type information (PFS; GAM or SGAM) when wait type is PAGELATCH_ or PAGEIOLATCH_.
Fixed parse page issue.
Added memory grant info, statements to blocking and blocked sections of blocking report, and fixed head blocker info.
Added information to blocking section, and fixed conversion issues.
Handle illegal characters in XML conversion.
support for SQL Server 2016 SP1 and live query plan snapshot.
Fixed transport-level error issue with SQL Server 2016 SP1.
I hope that the information on these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Ezequiel. Further, Ezequiel shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.