To check the query logs in SQL Server 2008 with a database compatibility mode set to 90.
Method 1
SELECT SQLTEXT.text,
STATS.last_execution_time
FROM sys.dm_exec_query_stats STATS
CROSS apply sys.Dm_exec_sql_text(STATS.sql_handle) AS SQLTEXT
WHERE STATS.last_execution_time > Getdate() - 1
ORDER BY STATS.last_execution_time DESC
Method 2
s.host_name,
s.login_name,
s.status,
st.text,
s.login_time,
s.program_name,
*
FROM sys.dm_exec_connections c
INNER JOIN sys.dm_exec_sessions s
ON c.session_id = s.session_id
CROSS apply sys.Dm_exec_sql_text(most_recent_sql_handle) AS st
ORDER BY c.session_id
No comments:
Post a Comment