Consider the following "code"
define stmt1 = 'insert into T(a, b) values(1, 1);
define stmt2 = 'select * from T';
MSSqlCommand.Execute( stmt1;stmt2 );
MSSqlCommand.Execute( stmt2 );
Investigating the cached query-plans using:
SELECT [cp].[refcounts]
, [cp].[usecounts]
, [cp].[objtype]
, [st].[dbid]
, [st].[objectid]
, [st].[text]
, [qp].[query_plan]
FROM sys.dm_exec_cached_plans cp
CROSS APPLY sys.dm_exec_sql_text ( cp.plan_handle ) st
CROSS APPLY sys.dm_exec_query_plan ( cp.plan_handle ) qp ;
My impression is that the first "Execute" generates a composite execution plan instead of two singular execution plans, thereby disabling the second "Execute" reusing any execution plan generated in the first Execute.
Am I right?