I was able to restore the query that I was working on after accidentally closing the tab. If you really executed the query, it should be in the SQL Server query cache. Request a query cache and arrange results by creation date. Additional information about SQL Server query cache:
Modify a query like this (found at http://msdn.microsoft.com/en-us/library/ee343986(v=SQL.100).aspx )
SELECT cp.objtype AS PlanType, OBJECT_NAME(st.objectid,st.dbid) AS ObjectName, cp.refcounts AS ReferenceCounts, cp.usecounts AS UseCounts, st.text AS SQLBatch, qp.query_plan AS QueryPlan FROM sys.dm_exec_cached_plans AS cp CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) AS st;
to get the desired result. The "st.text" column will have a query that was launched on the database server.
Pete
source share