How to recover the unsaved scripts if the SSMS crashes / unsaved tab gets accidentally closed?
A bit late to the party, but none of the previously mentioned locations worked for me - for some reason the back up/autorecovery files were saved under VS15 folder on my PC (this is for SQL Server 2016 Management Studio)
C:\Users\YOURUSERNAME\Documents\Visual Studio 2015\Backup Files\Solution1
You might want to check your Tools-Options-Environment-Import and Export Settings, the location of the settings files could point you to your back up folder - I would never have looked under the VS15 folder for this.
Maybe you don't find the suggested directories or your recovery file is missing, thanks god I replicated the crash with an unsaved script and lead me to this directory:
C:\Users\user\OneDrive\Documents\Visual Studio 2015\Backup Files\Solution1
So, maybe this saves your day :)
For SSMS 18, I found the files at:
C:\Users\YourUserName\Documents\Visual Studio 2017\Backup Files\Solution1
For SSMS 17, It was used to be at:
C:\Users\YourUserName\Documents\Visual Studio 2015\Backup Files\Solution1
Use the following location where you can find all ~AutoRecover.~vs*.sql
(autorecovery files):
C:\Users\<YourUserName>\Documents\SQL Server Management Studio\Backup Files\Solution1
For SSMS 18 (specifically 18.6), I found my backup here C:\Windows\SysWOW64\Visual Studio 2017\Backup Files\Solution1
.
Kudos to Matthew Lock for giving me the idea to just search across my whole machine!
You may be able to find them in one of these locations (depending on the version of Windows you are using).
Windows XP
C:\Documents and Settings\YourUsername\My Documents\SQL Server Management Studio\Backup Files\
Windows Vista/7/10
%USERPROFILE%\Documents\SQL Server Management Studio\Backup Files
OR
%USERPROFILE%\AppData\Local\Temp
Googled from this source and this source.