Saturday, September 12, 2009

Handy sql script to find lost quries

I always forget to save the quires that I'm executing against sql server and want to recover them without writing them back, here's a handy script which I use for this

select objtype,p.size_in_bytes,[sql].text
from sys.dm_exec_cached_plans p
outer apply sys.dm_exec_sql_text (p.plan_handle) sql
where [sql].[test] like '%Something goes here%'
order by usecounts desc

1 comment:

Anonymous said...

Danke sehr an den Webmaster.

Gruss Nadja