Recover Unsaved SQL Query Scripts

Recover unsaved SQL query scripts

Posting this in case if somebody stumbles into same problem.

Googled for Retrieve unsaved Scripts and found a solution.

Run the following select script. It provides a list of scripts and its time of execution in the last 24 hours. This will be helpful to retrieve the scripts, if we close our query window in SQL Server management studio without saving the script. It works for all executed scripts not only a view or procedure.

Use <database>
SELECT execquery.last_execution_time AS [Date Time], execsql.text AS [Script] FROM sys.dm_exec_query_stats AS execquery
CROSS APPLY sys.dm_exec_sql_text(execquery.sql_handle) AS execsql
ORDER BY execquery.last_execution_time DESC

Recover unsaved SQL query Scripts in Oracle SQL Developer

If you have the privileges then:

SELECT * FROM v$sql

If not then press F8 to bring up a list of previously ran queries.

Restore unsaved MySQL Workbench scripts?

You can try to find your script in History Output. Check this answer: MySql workbench query history ( last executed query / queries ) i.e. create / alter table, select, insert update queries

Can I restore recent query output in Oracle SQL Developer?

If you are using PL/SQL Developer, then you need to press CTRL+E. You can find Recent Executed Quer



Related Topics



Leave a reply



Submit