difference between StmtCompleted and BatchComplete | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

difference between StmtCompleted and BatchComplete

Hello all,<br /><br />When running SQL 2005 Profiler, there’re 2 choses that Iam looking at:<br />SQL<img src=’/community/emoticons/emotion-7.gif’ alt=’:S’ />tmtCompleted <br />sql:BatchComplete<br /><br />What’s the difference there? Seems like if I choose SQL<img src=’/community/emoticons/emotion-7.gif’ alt=’:S’ />tmtCompleted it will include batches as well. I would prefer not to duplicate what I capture.<br /><br />[<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]Thanks in advance
I’ve moved to relevant forum.
Luis Martin
SQL-Server-Performance.com All in Love is Fair
Stevie Wonder
All postings are provided “AS IS” with no warranties for accuracy.
If you are passing a single statement in a batch then, there is no difference between the batch and the statement. stmtcompleted will be same as batch completed<br /><br />However, the difference in batch complete and statement complete is evident only when you are having multiple statements in one batch.<br /><br />You can run profiler to capture both the following events:<br />SQL<img src=’/community/emoticons/emotion-7.gif’ alt=’:S’ />tmtCompleted <br />sql:BatchComplete<br /><br />and execute foll. query:<br /><br />/* Batch containing one statement */<br />select * from sysobjects <br />go<br /><br /><br />/* Batch containing multiple statements*/ <br />select * from sysobjects <br />select * from sysindexes<br />go<br /><br />See difference in from the output in Profiler.<br /><br /><br /><br />Regards,<br /><br />Chetan