Did you ever accidentally close SQL Server Management Studio?
Posted by Navi's on June 3, 2011
Did you ever accidentally close SQL Server Management Studio? And, in closing SSMS, did you get the prompt that says “Save changes to the following items?” And did you, completely unthinkingly, with a query you had just been working on, hit Cancel?
Try bellow query to get the executed query or procedure
SELECT dest.text FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest WHERE deqs.last_execution_time > '6/3/2011 07:00' AND dest.text LIKE 'xyz%';
You can get back your query. But you have to do a little formatting work, but it was immediately available.