Tom H
Tom H

Reputation: 47402

Where is SQLQuery1.sql saved?

Whenever I open up SSMS (SQL Server 2012), I get all of the scripts that I had open in my previous session. This includes both saved queries and any unsaved queries, which are listed as SQLQuery1.sql, SQLQuery2.sql, etc.

I can't seem to find where these "unsaved" queries are being saved. I've checked Documents\SQL Server Management Studio\Backup Files\ (and every other directory in that vicinity). I've also checked the C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\ directory and subdirectories (as best I could). Finally, I did a complete search on my computer for the filename SQLQuery1.sql and it turned up nothing (not that I trust the Windows search function in file explorer).

In case it changes things at all, I also have installed the Redgate SQL Prompt add-on for SSMS.

Any other suggestions?

Thanks!

Upvotes: 6

Views: 13432

Answers (3)

Shafiq-Ur-Rehman
Shafiq-Ur-Rehman

Reputation: 340

I got my saved query in the following way.

  1. I made another query and selected to save it.
  2. It popped out the save as dialogue box from where I got all the things which I required.
  3. I copied the file path which was "C:\Users\Shafiq Ur Rehman\Documents\SQL Server Management Studio"

enter image description here

Upvotes: 0

pkuderov
pkuderov

Reputation: 3571

It's very simple :)

Create new query, then right click on the tab and then choose Open containing folder option.

For example, I got C:\Users\PKuderov\AppData\Local\Temp folder and my SQLQuery4.sql is named ~vs3C67.sql.

So @BenjaminSmith is right but these files have unique temporary names. Until you explicitly save them where you want. It seems they survive ssms reload and you can further filter them by .sql extension and Date Modified.

Upvotes: 6

Benjamin Smith
Benjamin Smith

Reputation: 158

How about the TEMP folder? Try searching for %TEMP% from your start menu and searching in there.

Upvotes: 0

Related Questions