Clarifying misconception about RML Utilities

I remember in the past month addressing at least three different queries regarding RML Utilities on MSDN w.r.t. the co-relation between the Batches and Statements. Yes, it is true that a Batch will have one or more T-SQL statements. But if the statements do not have SP:StmtStarting and SP:StmtCompleted, then the Batch will not have an entry in the ReadTrace.tblStatements. This is documented in the RML Utilities help file. 

You can verify if the trace has any SP:StmtStarting or SP:StmtCompleted using the following query: 



select count(*) from fn_trace_gettable ('<trace file with full path>',null) where eventclass in (44,45)

From the help file: 


This table contains one row for each SP:StmtStarting or SP:StmtCompleted event in the trace. Similar to the ReadTrace.tblBatches table, the completed event is stored when it is available. Otherwise, the starting event is saved so that you can tell that a query was running when the trace was stopped.