Is there a tool, script, utility that can parse
sys.sql_modules and return a list of tables and columns referenced in the
GROUP BY, and
JOIN clauses of Stored Procedures?
CREATE PROC myProc BEGIN SELECT a.col1, b.col2, count(a.col7) as MyCount FROM dbo.FirstTable as a JOIN dbo.SecondTable as b on (a.col1 = b.col1) WHERE b.col5 = 'xxx' GROUP BY a.col1,b.col2 END
Return a list such as:
The goal is to use the result list to build some
CREATE STATS commands based on the number of times a
table.col pair is referenced.