Created
February 16, 2018 14:49
-
-
Save richardbasile/c24101a9c53e5b2fe7771b6816223525 to your computer and use it in GitHub Desktop.
SQL Server - Multiple Plans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT TOP 100 | |
query_hash AS [Query Hash] | |
, COUNT(query_hash) AS [Plan Count] | |
, ( | |
SELECT TOP 1 text | |
FROM sys.dm_exec_query_stats qs | |
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st | |
WHERE pc.query_hash = qs.query_hash | |
) AS [Query Text] | |
FROM sys.dm_exec_query_stats pc | |
GROUP BY query_hash | |
HAVING COUNT(1) > 1 | |
ORDER BY [Plan Count] DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment