--Client connection history
SELECT
@@SERVERNAME servername,
ess.[host_name],
ecs.client_net_address,
ess.login_name,
ess.[login_time],
ecs.client_tcp_port,
ess.[program_name],
ess.session_id,
ess.[database_id],
DB_NAME(database_id) AS [database_name],
num_reads totalreads,
num_writes totalwrites,
ecs.most_recent_sql_handle
FROM sys.dm_exec_sessions AS ess WITH (NOLOCK)
LEFT JOIN sys.dm_exec_connections AS ecs WITH (NOLOCK) ON ess.session_id = ecs.session_id
No comments:
Post a Comment