May 6, 2016 at 5:50 am
Hi Please suggest t-sql script executed from Last 24 hours with queries start time and Query execution date & time
t-sql script SQL queries Executed from last 24 hours with Data and time stamp
Thanks in Advance
May 6, 2016 at 6:26 am
Unless you had some custom monitoring, you're not going to get that.
You can query the plan cache (sys,dm_exec_query_stats cross apply sys.dm_exec_sql_text) to get the text and last execution time of distinct procedures/ad-hoc batches, assuming they still have plans in cache, but that's the best you're going to get. SQL does not store anywhere the actual data that was returned by each query. It can't, the memory/storage requirements would be prohibitive.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 6, 2016 at 6:27 am
unless you have an extended event or audit already in place, you cannot capture that data; SQL executes a query and throws it away, but it might save the plan(the fast way it determined to get the data).
you can get an idea of that small piece of it by looking at what is in the dmv's and the plan cache, dsomething like this is just one example:
SELECT
fn.*,
st.*
FROM sys.dm_exec_query_stats st
CROSS APPLY sys.dm_exec_sql_text(st.[sql_handle]) fn
if you are looking for whodunnit info (Did Lowell query the Payroll database?!?! did he access something he shouldn't?) that information is not captured, again, unless you put something in place to capture it.
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply