Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SELECT
total_uses =
(ddmigsq.user_seeks + ddmigsq.user_scans),
ddmigsq.avg_total_user_cost,
ddmigsq.avg_user_impact,
query_text =
SUBSTRING
(
dest.text,
(ddmigsq.last_statement_start_offset / 2) + 1,
(
(
CASE ddmigsq.last_statement_end_offset
WHEN -1
THEN DATALENGTH(dest.text)
ELSE ddmigsq.last_statement_end_offset
END
- ddmigsq.last_statement_start_offset
) / 2
) + 1
)
FROM sys.dm_db_missing_index_group_stats_query AS ddmigsq
CROSS APPLY sys.dm_exec_sql_text(ddmigsq.last_sql_handle) AS dest;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment