Here is how to do it in SQL 2008+
SELECT cp.plan_handle
, st.text
, 'DBCC FREEPROCCACHE (' + convert(varchar(max), cp.plan_handle, 2) + ');'
FROM sys.dm_exec_cached_plans cp
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS st
In SQL 2005
Could use undocumented function
master.dbo.fn_varbintohexstr
or XML
cast('' as xml).value('xs:hexBinary(sql:variable("column_or_variable"))', 'varchar(max)');
No comments:
Post a Comment