[I am a beginner level T-SQL Programmer]
[..and hopefully I am on the right stack exchange site]
I would like to get a list of all the queries I executed (in the least, those I executed today since morning). I need to make a report on the execution times of the queries.
Online search didn't yield me much useful info. The only query that I found online which seemed pretty close is
SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest ORDER BY deqs.last_execution_time DESC
This query returned some odd results (most of which were a bunch of sprocs). Moreover, all these results show queries executed since today afternoon (I need queries from morning).
I couldn't find anything in the previous questions (if similar question has already been asked, please point me to it).
I saw some suggestions regarding SQL Profiler, but I guess profiler would help me only if I have already started the trace (correct me if I am wrong).
Can someone suggest me how I should go about to get a list of all queries that have been executed on the database since morning (including the query execution times)..
[It would be helpful (not a requirement) if I can also somehow get the username of the user who executed the query]