This question already has an answer here:

We had a site slowdown between 11.57 am and 12:02 pm on 6th Aug 2018, To trace back the queries which were ran our production database (SQL Server Standard Edition 2012) and which might have caused a slow down , I would require help on how to find the queries which have been running on our database for last 15 days ?

If any dmv's or any other queries which can provide me the data above, kindly share.

Much Thanks!

marked as duplicate by John aka hot2use, Erik Darling sql-server Aug 6 '18 at 13:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Without tracing enabled, a query is not stored anywhere.( note: insert and updates are stored in the transactionlog, but that's not very convenient for performance tuning) Sure, you can look into DMV's, or the cache, but that is scraping off the data and you may end up nowhere. If you want to prepare for such performance question in the future, you can use an extended event trace, which captures the SQL-hash and the duration. I have a trace running every day, revolving each week, this helps me to resove such questions you have. ( and make performance and usage reports)

  • Hello Could you explain more how to use extended event trace? – Sayantani Nath Aug 8 '18 at 6:30
  • sure, give me 2 days to make a blogvideo on how I use extended this way. In case you're new to extended events, I have a blogpost on the system health session, that's the default trace. willemleenen.nl/?p=107 – Willem Aug 8 '18 at 8:17
  • Thanks @willem, will wait for the blog video as well. – Sayantani Nath Aug 8 '18 at 9:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.