Query Analyzer

  • Hi,

    Does anyone know if Query Analyzer stores all the queries that are executed into a history file and if so how do i view the last executed query which i did not save it.


  • I might be jumping the gun a bit but I'm pretty sure that you're out of luck. However, if there is such a feature do let me know because I'm forever closing QA windows without saving them.

    Good luck retrieving your query.

  • I think Toad for SQL Server (60 days freeware trial version from Quest software) includes this feature.


    If it ain't broke, don't fix it...

  • [off-topic]

    You can avoid losing unsaved queries by clearing the checkbox "Do not prompt for unsaved files on closure" in the QA options

  • Good old Microsoft. They always provide a tick box for any problems you're having. I'm still looking for the tick box in the .Net development environment that tells it to stop being so resource hungry.


  • your best bet could be in the transaction log.

    query analyser is not that forgiving

    Everything you can imagine is real.

  • The transaction log does not store a log of all queries.  It stores the changes that are made to a database.  It is also an unreadable entity.

  • FYI

    A product called Aqua Data Studio stores out a history of queries.

    It works with both Oracle and MS SQL .

    I have been working with their demo a little bit ; price is reasonable


  • FYI.

    Instead of figuring out how to find the last unsaved executed query in SQL QA,  I started using Teradata SQL Assistant tool which can be used against most of the databases and stores all the queries in a history file.  The cool thing about this tool is that history file is displayed right in this analyzer in a tabular format and you can just select and also search on whatever previous queries you might have executed.

    Thanks to all for your suggestions.

  • I was working on a remote machine and while I was away, the machine was restarted. Lost the scripts I had unsaved, or so I thought; and then I came up with this - was a life saver!



    FROM sys.dm_exec_query_stats EQS

    CROSS APPLY sys.dm_exec_sql_text(eqs.handle) EST

    WHERE EST.text LIKE '%text%'

    ORDER BY last_execution_time DESC


Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply