Someone was running a query on our SQL Server database remotely and their system crashed.
They have no backup of that query and want to see what was run on the server.
Is it possible to find this query in a log or in a history somewhere?
|
Someone was running a query on our SQL Server database remotely and their system crashed. They have no backup of that query and want to see what was run on the server. Is it possible to find this query in a log or in a history somewhere? |
|||||
|
|
Similar Grant Fritchey had the issue where he had closed SSMS and lost the query he had been working on...blogged about here: Oh ****! |
|||
|
|
You might be able to retrieve info from cached query plans, check BOL for info on sys.dm_exec_query_stats, or run this from management studio connected to the same database:
Filter the output with
to narrow the results. |
||||
|
|
|
2005+, default trace to the rescue. The default trace rolls over at 20mb but SQL retains the history of 5 traces. With access to the server you could retrieve the *.trc files from the MSSQL\Log directory. If you can't access the server, the following will give you the name of the current default trace file:
If the current file is for example E:\MSSQL.1\MSSQL\LOG\log_200.trc, the previous files should be log_199.trc, log_198.trc etc. Get the contents of the trace with:
|
|||
|
|
|
Not in a log. Checked into a TFS or SourceSafe version control system? Result set off to a txt so it can be recreated? |
|||
|
|