• Due to the use of Cross Apply, this will only return rows where the Statement and QueryPlans are available. Change it to an OUTER APPLY to gather all spids.

    ie

    OUTER APPLY sys.dm_exec_sql_text(sql_handle) AS Statements

    OUTER APPLY sys.dm_exec_query_plan(plan_handle) AS QueryPlans