How to recover the unsaved scripts if the SSMS crashes / unsaved tab gets accidentally closed?
I know this is an old thread but for anyone looking to retrieve a script after ssms crashes do the following
Go to SSMS >> Tools >> Options >> Environment >> AutoRecover
There are two different settings:
1) Save AutoRecover Information Every Minutes
This option will save the SQL Query file at certain interval. Set this option to minimum value possible to avoid loss. If you have set this value to 5, in the worst possible case, you can lose last 5 minutes of the work.
2) Keep AutoRecover Information for Days
This option will preserve the AutoRecovery information for specified days. Though, I suggest in case of accident open SQL Server Management Studio right away and recover your file. Do not procrastinate this important task for future dates.