HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Determine the server that sent a query

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
thequerysentthatdetermineserver

Problem

For the distributed queries, is it possible to determine the server that sent a query?

For example, I have stats:

SELECT DB_NAME(st.dbid),
text,
request_time,
query_plan,
(requested_memory_kb / 1024),
(granted_memory_kb / 1024),
query_cost
FROM sys.dm_exec_query_memory_grants AS mg
CROSS APPLY sys.dm_exec_sql_text(mg.sql_handle) AS st
CROSS APPLY sys.dm_exec_query_plan(mg.plan_handle) AS ph
ORDER BY requested_memory_kb DESC

How can I get server that sent each query? What tables should I join or functions to apply?

Solution

The DMV sys.dm_exec_sessions has column host_name which is the computer at the client end of the connection. You can join that to your posted query through the session_id.

Context

StackExchange Database Administrators Q#96044, answer score: 5

Revisions (0)

No revisions yet.