I'm looking for a DMV query for SQL Server 2008 R2 which shows me all queries (full history) run by a specific user.
I have this code for now:
SELECT *
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp
but is it possible to join another DMV which allows me to filter results on login name?
Best Answer
LoginName and Hostname from Sys.sysprocesses
you've already got a cross apply to dm_exec_Sql_Text. so you've already got everything else you need.