0

How to retrieve unsaved tabs on Azure Data Studio?

I was writing a long Azure SQL script that contained a cursor and while loop. And while I was dry-run ning it it crashed! I had not saved my work on this tab. I would like to retrieve the script so I do not have spend time writing it again.

StackRover
  • 557
  • 5
  • 10

1 Answers1

0

You can retrieve the unsaved sql script using below query

 USE  <databaseName>

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

ORDER BY execquery.last_execution_time DESC

It will retrieve the unsaved script

enter image description here

Along with that as per this In the latest version Azure data studio above issue is fixed. i.e. the unsaved scripts are not closed by ADS if it closed with any crashes. Try to check the version of ADS.

Bhavani
  • 1,725
  • 1
  • 3
  • 6