MSDN Archive Home
Help and FAQs
SQL Server Query Hash Statistics
All Resource Updates
Change History (all pages)
Quick Start Guide
Parts of Query Hash Statistics rely on the SQL Server Data Collector (DC) to harvest query stats data and upload it to a database for analysis. If you haven’t already created a Management Data Warehouse database and enabled data collection on your SQL Server instance, do this now:
Decide where to host the MDW database.
The MDW database host instance can be the same as the instance that you want to monitor, or it can be a different SQL instance.
Create your MDW database:
Connect SQL Server Management Studio (SSMS) to the SQL Server instance that you want to host the MDW database. If Object Explorer is not already visible, open it from the View drop-down menu.
Right-click on the "Management\Data Collection" node, and select "Configure Management Data Warehouse".
Choose the first option in the wizard, "Create or upgrade a management data warehouse", and click Next.
On the next dialog, click the New button to create the MDW database. This database will be referred to in this documentation as "MDW", but you can name it something else if you wish. It is OK to accept the default options for the remainder of the wizard.
Enable Data Collection:
Connect SSMS to the SQL Server instance that you want to collect query hash statistics from. (This may be the same instance as the MDW host, but it may also be a different SQL Server instance if you wish.) Launch the "Configure Management Data Warehouse" wizard again, but this time select the second option in the wizard, "Set up data collection". Choose the server that hosts the MDW database, and then select the MDW database in the drop-down list box.
The Query Hash Statistics collection set is very similar to the built-in "Query Statistics" system collection set. If you find that the Query Hash Statistics collection set meets your needs, you may wish to
stop the "Query Statistics" system collection set
to minimize data collection overhead and prevent the collection of redundant data.
For more information about creating a MDW database and enabling data collection, see the
Data Collection topics in Books Online
Installing Query Hash Statistics
Once you have created a MDW database and have enabled Data Collector on the instance where you will run Query Hash Statistics:
Download the latest release of Query Hash Statistics:
You can find this under the Downloads tab, above. Extract the files to a directory on a machine that has SSMS installed -- say, "C:\QueryHashStats".
Configure the MDW database
to receive data from the Query Hash Statistics collection set. To do this, connect SSMS to your MDW host instance and open the script
in a query window.
: You must manually change the database context to your MDW database before running the script
. Execute the script in this database. Check for errors.
Configure the Target Instance:
Using SQLCMD.exe, execute the script
on your target instance (the instance that you want to collect data from). There should be no errors, but this script will return a resultset, which you can ignore. To run the target server setup script via SQLCMD, open a command prompt and run a command like the one below (update the -S parameter value with your target SQL instance name). This command line assumes that your current NT account has sysadmin permissions on the target SQL Server instance. If you want to use a SQL authentication login like 'sa', instead, replace the "
" parameter with "
-U login -P password
SQLCMD -E -i C:\QueryHashStats\QueryHashStatsSetupTarget.sql -S <target_sql_server_instance>
The collection set takes a snapshot of query statistics once per minute, and it uploads its data once every five minutes.
Wait about ten minutes before attempting to use the reports.
Once at least ten minutes has elapsed:
Open the MDW Overview report:
To open a custom report, connect SSMS to your MDW host SQL Server instance, right-click on the MDW database node in Object Explorer, and select "Custom Report..." from the "Reports" submenu. Browse to the location of your query hash statistics reports and open
. You will not need to manually browse to the report after this; you'll find the report name in the Reports context menu. The first time you open a custom report, SSMS will ask you to confirm that you trust the report.
Once the report has opened, click on the "Query Hash Statistics" link to launch the analysis reports for the Query Hash Statistics collection set.
We hope Query Hash Statistics makes your day a little bit easier. Please let us know about your experiences -- good or bad -- in the Discussions tab, above. If you have a suggestion or think you've found a bug, please open a new issue under the Issue Tracker tab. Thanks!
(Continue reading about the
query fingerprint reports
, or return to the
Nov 30 2010 at 4:44 AM
, version 22
Jun 21 2011 at 11:14 PM
I have done all the steps to install the Query Hash Statistics and they all worked, but now when I try to run the report I get a "Invalid object name " 'core.spapshots' " error.
Any idea of what could be the cause of this?
Feb 23 2012 at 8:40 PM
Vladimir, not sure if your still following this thread but I had the same error and here is what I did: I ran the QueryHashStatsSetupTarget.sql script directly in SSMS in each target instance that I wanted to monitor, rather then using SQLCMD, just to visually see the scripts working. Then I opened the QueryHashStatsReports.sln directly in Visual Studio. I had to upgrade it to the current version that I use. Then I used Solution Explorer and double clicked on the Shared Data Source: MDW.rds and pointed it to the collections server where my MDW database is installed in my environment.
This solved my problem and I was back in business.
I hope this helps!
Sign in to add a comment
Fri Feb 22 2013 at 8:00 AM
More Tags ...
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.