Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 717 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recover unsaved SQL query scripts

#11
I use the free file searching program [Everything][1], search for *.sql files across my C: drive, and then sort by Last Modified, and then browse by the date I think it was probably last executed.

It usually brings up loads of autorecovery files from a variety of locations. And you don't have to worry where the latest version of SSMS/VS is saving the backup files this version.

[![enter image description here][2]][2]


[1]:

[To see links please register here]

[2]:
Reply

#12
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!
Reply

#13
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 [version]\Backup Files\Solution1

ex:

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.
Reply

#14
I know this is an old thread but for anyone looking to retrieve a script after ssms crashes do the following

1. Open Local Disk ©:
2. Open users Folder
3. Find the folder relevant for your username and open it
4. Click the Documents folder
5. Click the Visual Studio folder or click Backup Files Folder if visible
6. Click the Backup Files Folder
7. Open Solution1 Folder
8. Any recovered temporary
files will be here. The files will end with vs followed by a number
such as vs9E61
9. Open the files and check for your lost code.
Hope that helps. Those exact steps have just worked for me. im using Sql
server Express 2017

ex:

C:\Users\[YourUsername]\Documents\Visual Studio [version]\Backup Files\Solution1

Reply

#15
None of the options above have helped me recover a query I have executed on a remote machine 4 days ago whose script file wasn't saved and got lost due to a corporate restart.

I ended up recovering my query with the help of the system views *sys.query_store_query* and *sys.query_store_query_text*.

SELECT t.query_sql_text
FROM sys.query_store_query_text t
INNER JOIN sys.query_store_query q
ON t.query_text_id = q.query_text_id
WHERE q.last_execution_time between '2021-06-30' and '2021-07-03'
Reply

#16
If you still haven't found the recovery folder, you can try the following:

- Open SSMS.
- Write some query on it.
- Wait for a while to ensure the file is silently saved.
- Open the Task Manager and terminate the SSMS application.
- Reopen SSMS. You should be prompted to open your unsaved work.
- Open the proposed file and hover over the file tab to see its location.

Reply

#17
If you happen to have RedGate tools for SSMS, then they have a really useful tool called Tab History which will show you all of your open **and closed** tabs (even scripts which you wrote and closed without executing).

There should be a button on the Toolkit toolbar which looks like this which will open a window with a list of all scripts (which also has a search feature so you can search for your script):
[![screenshot of Tab Search button][1]][1]

I know that this won't be relevant for most people, but it might help someone out there who has lost their work...


[1]:
Reply

#18
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 name>\OneDrive\Documents\Visual Studio \<version>\Backup Files\Solution1

So, maybe this saves your day :)
Reply

#19
**This is for the Apple / Mac Os computers:** <br>

I was using `Azure Data Studio`:

You should be able to retrieve the unsaved scripts on your local:<br>
`/Library/Application Support/azuredatastudio/Backups/<numbered folder>/untitled`

The files will have a `-` prefix. For example: `-635baea3`
I had to review these folders and files and searched by date

you may open these files using vim:<br>
`vim ./-635baea3`

Hope this is useful.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through