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
For Autoincrement Fields: Max(Id) VS Top 1 Id Order by Id Desc
Transact-SQL Shorthand Join Syntax
SQL Oracle Left Join and Subquery Error: Ora-00905: Missing Keyword
Laravel Eloquent to Join Table and Count Related
With Hibernate, How to Query a Table and Return a Hashmap with Key Value Pair Id>Name
Postgresql Does Not Use a Partial Index
Oracle Connect by Clause Equivalent in SQL Server
"Ora-01438: Value Larger Than Specified Precision Allowed for This Column" When Inserting 3
Rand Not Different for Every Row in T-SQL Update
SQL Find Difference Between Previous and Current Row
SQL Left Join Losing Rows After Filtering
Using Dynamic SQL to Specify a Column Name by Adding a Variable to Simple SQL Query
Return Rows from Insert with on Conflict Without Needing to Update
SQL - Find Missing Int Values in Mostly Ordered Sequential Series
SQL Server: How to Get a Database Name as a Parameter in a Stored Procedure