SQL Server Diagnostic Information Queries for May 2021


These are my SQL Server Diagnostic Information Queries for May 2021, aka my DMV Diagnostic Queries. They allow you to get a very comprehensive view of the configuration and performance of your SQL Server instance in a short amount of time. These are my SQL Server Diagnostic Information Queries for May 2021.

There are separate versions of these T-SQL queries for SQL Server 2005 through SQL Server 2019. I also have separate versions for SQL Managed Instance and Azure SQL Database. My diagnostic queries have been used by many people around the world since 2009. I make regular improvements to these queries each month.

SQL Server Diagnostic Information Queries for May 2021
SQL Server Diagnostic Information Queries for May 2021

Monthly Improvements

This month, I have improved the Total Buffer Usage by Database query to not have an integer overflow on servers with very larg amounts of RAM. As always, I have made additional small improvements and corrections to all of the versions of these queries.

Making YouTube videos about these queries has forced me to look at some of them with a new perspective. This video walks through all of the Diagnostic Information queries from the SQL Server 2019 set.

BTW, I often make additional minor updates to the queries periodically during the month, so if you are in doubt, downloading the latest version is always a good idea. They are always available from my Resources page.

Rather than having a separate blog post for each version, I have just put the links for all eleven major versions in this post. There are two separate links for each version. The first one on the top left is the actual diagnostic query script, and the one below on the right is the matching blank results spreadsheet, with labeled tabs that correspond to each query in the set.

Here are links to the latest versions of these queries for SQL Managed Instance, Azure SQL Database, and all available versions of SQL Server:

Azure Diagnostic Queries

SQL Server Diagnostic Queries

Legacy SQL Server Diagnostic Queries

Usage Instructions

The basic instructions for manually running these queries is that you should run each query in the set, one at a time. You should read the directions for each query and my comments on how to interpret the results. It is not a good idea to simply run the entire batch in one shot. This is especially true the first time you run these queries on a particular server. Some of these queries can take some time to run, depending on your workload and hardware.

It is very useful to run each query, look at the results and think about the emerging picture of what is happening on your server. I have quite a few comments and links in the script on how to interpret the results after each query.

Saving the Results

After running each query, you click on the top left square of the results grid in SQL Server Management Studio (SSMS) to select all of the results. Next, you right-click and select “Copy with Headers” to copy the results, including the column headers to the Windows clipboard. Finally, you paste the results into the matching tab in the blank results spreadsheet.

About half of the queries are instance specific and about half are database specific. Because of this, make sure you are connected to a database that you are concerned about! Make sure you are not connected to the master system database. Running the database-specific queries while being connected to the master database is a very common mistake. As a result, I often see people make this mistake when they run these queries.


Note: These queries are stored on Dropbox. I occasionally hear that the links to the queries and blank results spreadsheets don’t work. This is usually because Dropbox is blocked where someone is trying to connect. I am not planning on moving these to Github any time soon, but I could change my mind.

Unfortunately, I sometimes get reports that some of the queries simply don’t work. This usually happens with an incorrect version of the script for the version of SQL Server. Sometimes, it turns out to be an issue where people have some of their user databases in 80 compatibility mode. This will break many DMV queries.

It is important that you are running the script that matches the version of SQL Server that you are running. There is an initial query in each script that confirms that you are using the correct version of the script. If you are not using the correct version of these queries, you will have problems.

Checking Spectre/Meltdown Status

In addition, I have a T-SQL script to check whether an instance of SQL Server has been patched to mitigate against the Spectre/Meltdown CPU vulnerability. This query works for SQL Server 2008 through SQL Server 2019, for on-premises and cloud-based VM (IaaS) usage. SQL Server 2019 actually has this fix in all builds, so you don’t have to check SQL Server 2019 instances. You can get the query for this here.

Please let me know what you think of these queries, and whether you have any suggestions for improvements. Thanks!

I recorded a PASS Summit session in October of 2020 featuring the Juypter notebook version of these queries. The video for that is embedded below.

Dr DMV with Jupyter Notebooks

Additional Resources

If you want to understand how to better interpret these queries, you should listen to my YouTube videos that walk through how to interpret the results of each of these queries.

These are the ones I have completed so far:

Watching and “liking” these videos is really the best way to thank me for maintaining and improving these scripts…

If you have any questions about this post, please ask me here in the comments or on Twitter. I am pretty active on Twitter as GlennAlanBerry. Thanks for reading!

4 thoughts on “SQL Server Diagnostic Information Queries for May 2021

  1. Do you have any plans to release a Linux-targeted set of queries at any time? Some of the queries don’t apply, in full or in part, and for those of us with SQL, but not Linux, expertise, knowing what is real/irrelevant could help. Queries as-is are a huge benefit, so Thanks!

    1. The vast majority of these queries do work on SQL Server 2017 or newer running on Linux. The main ones that don’t (that I am aware of) are the ones that read from the Windows Registry. Ideally, Microsoft would expose the same information vis a new or extended DMV, so I would not have to pull from the Windows Registry. I have tried to talk them into doing that, with no luck so far.

  2. Hi Glenn,
    I have downloaded the latest queries for Azure Managed Instance. I have question about Query 14 (IO latency by file). The helpful comments mention move some files to different location. Is this query still valid for Managed instance where we don’t have access to the file system. In MI, you get more IOPS as you increase the size of the file. I want to know when I am reaching the limit of IOPs for a particular file before I need to increase the size of the file.
    Thank you.

    1. I need to update the comments for that set of queries

Please tell me what you think

search previous next tag category expand menu location phone mail time cart zoom edit close