There is no single "unsaved files" folder in SQL Server. If you mean work you had open but never saved—an SSMS query tab, a script, or a table edit—recovery depends on whether the application was still running, whether it crashed, and whether the data ever reached the database engine. Your best odds come from three places: SSMS's autosave recovery folder, temp files the editor wrote, and the database's own write-ahead transaction log. The key condition is timing: once an SSMS instance closes normally even by crash recovery, its unsaved tab content is usually gone unless an autosave copy survives.
This guide walks through those cases in a sensible order, from cheapest and most reversible checks to the heavier database-side recovery. It assumes you're on Windows with a typical SQL Server Management Studio (SSMS) install, and it calls out where Azure Data Studio, Visual Studio Code with the SQL extension, or a different SQL client changes the answer. Where I mention file paths or feature behavior, treat them as default-configuration guidance to verify on your machine; Microsoft changes defaults between versions, and I can't check your specific build here.
First, identify which kind of "unsaved" you're dealing with
"Unsaved files" in SQL Server work usually means one of four things, and each has a different recovery route:
1: Unsaved query text you typed in an SSMS or Azure Data Studio tab and never saved to disk, then the app crashed or closed. 2: Unsaved table data edits made through the grid editor (Edit Top 200 Rows), where you changed cells but never clicked away to commit. 3: Uncommitted transactions in a script you ran, where the changes exist in the database but were never committed and the session died. 4: A lost script file you did save once but can no longer find, or a query you ran ad hoc from a file that has since moved.
The distinction matters because the first two live in the client application's memory or temp storage, the third lives in SQL Server's transaction log, and the fourth is a file-system search problem. Matching your situation to the right bucket saves you from wasting time on a recovery method that can't possibly apply.
A rough test: if the SQL Server service restarted or the machine rebooted, unsaved editor text is the fragile case. If only your query window closed but the server kept running, uncommitted transactions may still be open in a session, or already rolled back. If the database itself is suspect, that's a backup-and-log problem, not an unsaved-file problem.
Recover unsaved SSMS query tabs from autosave and temp files
SSMS keeps recovery copies of open query tabs so it can restore them after an unexpected shutdown. The behavior has shifted across versions—older SSMS releases used a ~AutoRecover folder and a ~vs.sql naming scheme, while later versions consolidated recovery data under a per-user backup location tied to the SSMS version number. Because the exact path differs by version, find it rather than guess.
Prerequisites: the SSMS process that held the unsaved work has already exited (crashed, was killed, or you closed it), and you have not since opened and saved over the same tab in a way that overwrote the recovery copy. Do this before reinstalling or resetting SSMS settings.
1: Close SSMS if it's currently open, so it doesn't overwrite recovery files on exit. 2: Open File Explorer and navigate to your user profile's SSMS settings area. The usual root is %USERPROFILE%\Documents\Visual Studio 20XX\Backup Files\ for older shells, and %APPDATA%\Microsoft\SQL Server Management Studio<version>\ for newer ones. If neither exists, paste %APPDATA% into the address bar and look for a SQL Server Management Studio folder. 3: Inside, look for a Backup Files, AutoRecover, or similarly named folder, then a project or solution subfolder. Recovery files typically carry the original name plus a .vs or ~ marker, or a random-looking hex prefix with a .sql extension. 4: Sort by Date Modified descending. Your lost tab is almost certainly the newest .sql-type file modified around the time of the crash. 5: Open candidates in Notepad first—not SSMS—so you don't trigger another save. Confirm the text is yours, then copy it into a new SSMS tab and save it properly to a real folder.
On relaunch after a crash, SSMS often prompts to recover auto-saved documents; accepting that prompt is the fastest route and restores tabs directly. If you dismissed the prompt, the files above are your fallback.
Success check: you've recovered the text and saved it to a path you control (for example, a project folder synced to OneDrive or a Git repo). Failure case: no recovery files exist, or the newest ones are empty stubs. That usually means the tab never triggered an autosave (very new tab, no edits), the recovery feature was disabled, or a clean close purged them.
The same idea applies to Azure Data Studio, which keeps untitled and hot-exit buffers; its recovery behavior and file locations are documented separately and differ from SSMS, so don't assume the SSMS path applies. If you typed into an untitled ADS tab, check ADS's own backup/hot-exit settings before concluding the text is gone.
Use temp files and Windows file recovery as a second pass
If the autosave route comes up empty, the editor or OS may still have a copy. Two low-cost checks:
Editor temp files: some clients write scratch copies next to the target or in %TEMP%. Search %TEMP% for .sql, .tmp, or files modified within the last hour. Windows File History / Previous Versions: if the lost file had been saved to a folder covered by File History or volume shadow copies, right-click the folder, open Properties, and check the Previous Versions tab. This only helps for files that existed on disk, not text that never left memory.
A targeted search beats scrolling. In Explorer's search box, use datemodified:today kind:document scoped to your Documents and %TEMP% folders, or search for a distinctive phrase you remember typing if the client wrote it to a cache. Keep searches narrow to avoid drowning in unrelated files.
Stop condition: if the lost work is regulated data and you're considering third-party "file recovery" utilities that scan raw disk, pause. On a production database server, installing recovery tools or writing to the same volume can reduce the chance a professional can recover the file. Involve whoever owns the server's data-protection policy first.
Recover unsaved table edits before they commit
The grid editor in SSMS (and similar tools) is deceptive: changing a cell can hold the change in the client while the row sits in an editable but uncommitted state. If the tool crashes or you close it without navigating off the row, the edit can vanish.
Recovery here is mostly preventive and immediate:
Before closing, click into another row or press the tool's commit control so the change is sent to the server. Many grid editors commit when you move focus; some require an explicit save. If the client is still open but the grid looks wrong, refresh the table and check whether the value actually persisted. If it did, you're done. If it didn't, the edit was never sent. If the client already closed, a grid edit that was never committed is gone—there's no server-side record of a change the server never received.
This is the case where "unsaved" is nearly unrecoverable by design. The practical lesson is to make edits through explicit UPDATE statements in a script you save, or through a client that shows a clear pending-changes indicator and warns on close. That converts a silent loss into a visible commit step.
Recover uncommitted transactions from the transaction log
If your script opened a transaction, made changes, and the session died before COMMIT, SQL Server rolls the transaction back on recovery—so those specific changes are typically gone. The transaction log is the place to look if you need to see what happened or if the database is in a state where you're reconstructing activity. This is the heaviest, most expert-dependent route, and it's not a substitute for backups.
Prerequisites: you have access to the database and its transaction log backups, the recovery model is FULL or BULK_LOGGED (SIMPLE truncates the log and loses this history), and you understand that point-in-time restore overwrites the database. Do not experiment on production; use a restored copy.
1: Confirm the recovery model: run SELECT name, recovery_model_desc FROM sys.databases WHERE name = 'YourDb'; in a query window. 2: If it's FULL, check that log backups exist and are recent. Without a valid log chain, point-in-time recovery isn't possible. 3: Restore the most recent full backup to a different database name, then apply log backups with WITH NORECOVERY in sequence. 4: Apply the final log with WITH RECOVERY, STOPAT = '' to land just before the bad event, if your goal is to recover to that moment. 5: On the restored copy, query the affected tables or use a log-reading technique built into your tooling to inspect what the transaction did.
Success check: the restored copy shows the data as of your target time and you can verify row counts or specific values against expectations. Failure case: the recovery model is SIMPLE, a log backup is missing, or the log was truncated—then point-in-time recovery isn't available and your fallback is the last good full backup plus whatever you can reconstruct from application logs or exports.
Third-party log readers exist that parse transaction log records to display changes, including some uncommitted activity. They can be useful for forensics, but they're not a guaranteed recovery path, their results vary by SQL Server version, and you should validate any output against a test restore rather than trusting it blindly. Because this touches backups, retention, and potentially regulated data, the safe move on any production system is to hand the restore and log analysis to your DBA or the team that owns backups—especially when the question is "recover to the instant before an incident" rather than "find my lost script."
Find a query file you saved but can't locate
If the script was saved at some point, this becomes a search problem rather than a recovery problem. Fast checks:
SSMS recent files: the File menu's recent list and the Start Page often point at recently opened scripts. Search by content: Explorer can't search file contents by default across all locations, but findstr /s /i "distinctive phrase" .sql in Command Prompt, run from a drive root, will scan folder by folder. Narrow the start folder to keep it quick. Version control: if the script lived in a Git repo, git log --all -- '.sql' and git grep can find it even after a rename. Recycle Bin and shadow copies: deleted files may be recoverable from the Recycle Bin or the Previous Versions tab described earlier.
The check is simple: once found, copy it to a location under version control so this doesn't recur.
Prevent the next loss: settings and habits that actually help
Recovery is the fallback; these habits make it rare:
Turn on autosave recovery and verify it works by opening a scratch tab, typing, killing the process, and relaunching to confirm the prompt appears. A feature you haven't tested is a feature you don't have. Save early to a real path. Untitled tabs are the most fragile. Even a quick Ctrl+S to a working folder changes your odds dramatically. Use a version-controlled scripts folder (Git, or at minimum a cloud-synced folder) so "saved" also means "recoverable after disk failure." Prefer explicit transactions you can see. BEGIN TRAN / COMMIT in a saved script, with a clear review step, avoids silent grid-edit loss. Keep FULL recovery plus tested log backups on databases where point-in-time matters, and actually test a restore on a schedule. An untested backup is a hope, not a plan. Don't rely on one client's autosave. Different SQL clients store recovery data differently and change defaults between versions; know your specific tool's behavior.
What each path can and can't recover
A fair comparison comes down to the same criteria across methods: what kind of loss it addresses, what you need in place beforehand, and how reliable it is.
| Situation | Best first route | Needs beforehand | Reliability |
|---|---|---|---|
| Unsaved query text after crash | SSMS/ADS autosave recovery | Recovery feature on, not overwritten | High if copy survives |
| Unsaved grid cell edit | Commit before closing | Client that commits on focus change | Low after close |
| Uncommitted transaction | Restore copy + log review | FULL recovery model, intact log chain | Depends on backups |
| Saved file can't be found | File/content search, VCS | File existed on disk | High |
The mismatch to notice: the first and fourth rows are recoverable with local effort, while the third row depends entirely on infrastructure you set up in advance. Method and timing, not effort, determine which row you're in. None of these tables substitute for testing on your own versions, because SSMS and SQL Server defaults shift between releases and Microsoft documents the current behavior per version.
For a concrete worked estimate: suppose you lose a 40-line query at 2:15 p.m. after a tab that autosaved at 2:10. If the recovery folder contains a file modified at 2:10, you recover roughly the state as of 2:10 and lose up to about 5 minutes of typing—an amount you can bound by the autosave interval and the file's timestamp. That arithmetic is why checking Date Modified on candidate files, rather than opening them all, tells you quickly whether the newest copy is worth chasing.
Common mistakes that destroy your only copy
A few actions reliably make things worse:
Reopening SSMS and saving the same tab before checking recovery files can overwrite the recovery copy with an empty buffer. Running repair or "cleanup" utilities on the SSMS settings folder or %TEMP% before you've searched it. Restoring a backup over the live database to "see what happened," which overwrites current data and removes your ability to compare. Trusting an untested backup chain when the log has a gap; the restore will fail at the gap, not at your target time. Installing disk-recovery software on the affected volume when a professional recovery path is still viable.
FAQ
Does SSMS save unsaved queries automatically?
It keeps recovery copies of open tabs so it can restore them after an unexpected shutdown, and it typically prompts on relaunch after a crash. It does not silently save every keystroke to your chosen folder, and a clean close can discard recovery data—so treat it as crash insurance, not a save button.
Can I recover a query I never saved if SSMS closed normally?
Usually not from the editor. If the tab had been open long enough to trigger an autosave copy and that copy wasn't overwritten, it may still be in the recovery folder; otherwise the text lived only in memory and is gone. This is why saving to a real path early matters.
Can I recover an uncommitted transaction after the session died?
SQL Server rolls back uncommitted transactions on recovery, so the changes themselves are typically not applied. You can reconstruct activity from the transaction log only if the database uses FULL or BULK_LOGGED recovery and the log chain is intact—and you do that on a restored copy, not the live database.
Where does Azure Data Studio keep unsaved work?
ADS has its own hot-exit and backup behavior separate from SSMS, with its own file locations and settings. Check ADS's documentation for your version and its hot-exit setting rather than reusing the SSMS path.
Is a third-party log reader safe for production recovery?
It can help you inspect what a transaction log recorded, but results vary by SQL Server version, and running unfamiliar tools near production data carries risk. Validate any output against a test restore, and let your DBA own production recovery decisions.