1

I had one important unsaved query in SQL Management Studio. Accidentally I closed that tab and now I need to retrieve that query. Is there anyway?

SQL Management Studio Version: Microsoft SQL Server Management Studio 12.0.2569.0

Update: I checked at Recover unsaved SQL query scripts link and I did not find my query files there.

I executed that query multiple times yesterday.

Anand Shah
  • 366
  • 1
  • 4
  • 18
  • https://stackoverflow.com/a/3579148/1080354 – gotqn Oct 17 '17 at 06:12
  • The question is, did you execute that query? If so, you're able to retrieve it – Magisch Oct 17 '17 at 06:19
  • 2
    Possible duplicate of [Recover unsaved SQL query scripts](https://stackoverflow.com/questions/15034832/recover-unsaved-sql-query-scripts) – MatSnow Oct 17 '17 at 06:20
  • For future reference, do yourself a massive favour and install one of the great add-ons that allow you to recover queries, tabs or entire sessions, plus give you a gazillion other features that should be part of standard SSMS. My personal favourite is SSMSBoost (no affiliation, just a very impressed user, rather than link directly to it I'll leave you to Google options and decide for yourself). – pcdev Oct 17 '17 at 07:05
  • Oh, and I feel for you... before finding that add-on I must have lost dozens, maybe hundreds of hours productivity making stupid mistakes like accidentally closing unsaved queries... – pcdev Oct 17 '17 at 07:10
  • question updated – Anand Shah Oct 17 '17 at 10:03
  • @gotqn that query returns the list of queries till yesterday evening. I executed that query yesterday noon. – Anand Shah Oct 17 '17 at 10:05
  • 1
    @AnandShah I remember a few years ago being in the same situation. I have lost few hours in order to recover my lost query. I did not succeed. After that, I am always saving the file (using cntr+s) - the files is saved in the SSMS folder by default. My advice is to start saving what you type - at least the complicated things. – gotqn Oct 17 '17 at 10:09
  • I'm afraid that if you can't recover your query with the question marked as possible duplicate then it's lost forever. Unsaved changes are by definition not saved in disk, unless the program support session state (like a browser) after closing or crashing you can't recover unsaved data (even the method for recovering the query relies on the database server, it don't recover data directly from SSMS). As noted in other comments `Ctrl+S` is your friend. – Alberto Martinez Oct 17 '17 at 11:26

0 Answers0