SQL Server 2005 Management Studio - Restore accidentally closed tabs

Is there a way to do this if an unsaved tab is accidentally closed?

+6
sql-server-2005
source share
7 answers

I don’t believe that. I checked the msdn website and there is a thread about it, but the answer is no.

+2
source share

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.

+24
source share

I also found on the MSDN website that it was not possible to recover these files, but I would try to do it (it worked for me):

  • Look in the folder C: \ Users \ YOURUSERIDHERE \ Documents \ SQL Server Management Studio \ Backup Files \ Solution1 and select the files for the date when the machine restarted or crashed. SQLBlog.com

  • Take a look in the folder C: \ Users \ "[your username goes here]" \ AppData \ Local \ Temp \ (this did not work for me because my .sql files had 0KB and .tmp the files had something, but I could not find a way to β€œextract” the code from these .tmp files). Assume that this can sometimes be useful, depending on the cause of the reboot / system crash. ayesamson.com

+4
source share

I'm not sure what it is, but using TimeSnapper can help show what was previously in the window.

+3
source share

Go to "My Documents" \ SQL Server Management Studio Express \ Backup Files \ Solution1, you will find Restored backups. This is the only solution.

+2
source share

1. Look in the folder C: \ Users \ YOURUSERIDHERE \ AppData \ Local \ temp, then sort the files by date and select the last .sql, the size of which exceeds 0 bytes. It worked for me.

0
source share

Unfortunately, SSMS does not currently have the "Disable Closed Tab" feature. I created the following Connect element, so Microsoft will hopefully add this to a future version: https://connect.microsoft.com/SQLServer/Feedback/Details/1044403

-one
source share

All Articles