Question related to STATISTICS IO

  • Eg:

    SET STATISTICS IO ON

    SELECT * FROM Table-Name

    SET STATISTICS IO OFF

    STATISTICS IO generates IO related information.

    Is there any way of inserting those information directly into a table?

    Thanks for your time.

  • You can get the same information by running following query

    SELECT * FROM

    sys.dm_exec_query_stats

    CROSS APPLY

    sys.dm_exec_sql_text(sql_handle)

    I hope this helps

  • this one as well..

    SELECT SUBSTRING(text,

    -- starting value for substring

    CASE WHEN statement_start_offset = 0

    OR statement_start_offset IS NULL

    THEN 1

    ELSE statement_start_offset/2 + 1 END,

    -- ending value for substring

    CASE WHEN statement_end_offset = 0

    OR statement_end_offset = -1

    OR statement_end_offset IS NULL

    THEN LEN(text)

    ELSE statement_end_offset/2 END -

    CASE WHEN statement_start_offset = 0

    OR statement_start_offset IS NULL

    THEN 1

    ELSE statement_start_offset/2 END + 1

    ) AS TSQL,

    *

    FROM sys.dm_exec_query_stats

    CROSS APPLY sys.dm_exec_sql_text(sql_handle);

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply