• There are basically two good ways to get query metrics out of the system. You can query the cache and see what's there for query performance, or you can audit the queries. To query the cache, you can just select from sys.dm_exec_query_stats. You can combine that with sys.dm_exec_sql_text and sys.dm_exec_query_plan to get the statement text and the execution plan. A very simple query would be done like this:

    SELECT *

    FROM sys.dm_exec_query_stats AS deqs

    CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest

    CROSS APPLY sys.dm_exec_query_plan(deqs.plan_handle) AS deqp;

    From there you can select more or less columns, order by information as needed, etc. To audit queries, assuming you're on SQL Server 2008 or better, I strongly recommend using extended events. Here's an introduction to them.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning