SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 what SQL queries ran on a particular date?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

raaj
Posting Yak Master

127 Posts

Posted - 03/26/2014 :  23:48:07  Show Profile  Reply with Quote
Hello,

Is it possible to know what SQL queries ran on a particular date (eg say 01/02/2014) on a database?
Any ideas?

Thanks,
Raaj.

denis_the_thief
Aged Yak Warrior

Canada
594 Posts

Posted - 03/31/2014 :  16:27:16  Show Profile  Reply with Quote
No really.

I have a query below. It can give some insight. But it only gives you the 1st run and most recent run, so if your query was run more then twice, you are just guessing. Also this only goes back so far. But worth a try:

SELECT TOP 5000
a.Last_Execution_Time,
cast(last_elapsed_time/1000000.0 as decimal(10, 3)) Last_Elapsed_Seconds,
cast(max_elapsed_time/1000000.0 as decimal(10, 3)) Max_Elapsed_Seconds,
cast(total_elapsed_time/1000000.0/Execution_count as decimal(10, 3)) Avg_Seconds,
Execution_Count,
db_name(dbID) Database_Name,
object_name(ObjectID, dbID) Object_Name,
SUBSTRING(b.text, (a.statement_start_offset/2) + 1,
((CASE statement_end_offset WHEN -1 THEN DATALENGTH(b.text) ELSE a.statement_end_offset END
- a.statement_start_offset)/2) + 1) AS statement_text,
total_worker_time as CPU_time, a.*
FROM
sys.dm_exec_query_stats a CROSS APPLY
sys.dm_exec_sql_text (a.sql_handle) AS b
where
db_name(dbID) = ['Your Database Name']
ORDER BY
1
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000