Is there a way to capture STATISTICS IO and TIME within T-SQL for logging.
+1
A:
No, not using SET STATISTICS IO ON
.
But then you don't need to; run SQL Profiler and start a trace to output to a file. Include Reads and Duration.
Mitch Wheat
2010-06-05 11:43:58
+2
A:
Sort of. The same statistics as those given by SET STATISTICS TIME are captured by the query statistics DMVs like sys.dm_exec_query_stats
. The DMVs are queryable from T-SQL. The SET STATISTICS IO are only captured as an aggregate value (last_logical_reads, last_physical_read) per execution without the differentiation per-rowset given by SET STATISTICS IO. Overal though the DMV can serve the same purpose as SET STATISTICS IO.
Remus Rusanu
2010-06-05 20:08:35
Thanks a lot.. thats is exactly what I wanted..
TonyP
2010-06-10 11:45:25