Reputation: 317
Messed with SQL Sentry, I guess it could be done with a trace as well. Any recommended ways to watch/log the queries of a particular user? Logging it anytime they run it. i.e. if they ran it at night?
Upvotes: 0
Views: 7293
Reputation: 943
Try to use SQL Server system functions: Execution Related Dynamic Management Views and Functions (Transact-SQL)http://msdn.microsoft.com/en-us/library/ms188068.aspx
For example:
exec sp_who;
select a.session_id, st.text as QueryText from sys.dm_exec_connections a CROSS APPLY sys.Dm_exec_sql_text(a.most_recent_sql_handle) st where a.session_id = SessionID;
Upvotes: 2