8

Anybody know how I can list the prepared statements that are in a SQL Server instance?

Thomas Stringer
  • 42,434
  • 9
  • 120
  • 155
dublintech
  • 1,559
  • 8
  • 21
  • 26

1 Answers1

11
select
    cp.objtype,
    st.text
from sys.dm_exec_cached_plans cp
cross apply sys.dm_exec_sql_text(cp.plan_handle) st
where cp.objtype = 'prepared'

That above query will return all of the prepared plans that are cached, as well as their corresponding SQL text.

Thomas Stringer
  • 42,434
  • 9
  • 120
  • 155