Audit SQL Logins & Process PIDs to SQL Queries

How to Trace Remote Desktop User Processes to SQL Queries?

At times, users with shared SQL logins may have several processes which query the database. With hundreds of users on RDS, tracking down an offending query may become complicated. It need not be so.

First, list all the queries which are running on the SQL server. 

SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time,
s.login_name,
s.host_name,
s.host_process_id,
s.login_time
FROM sys.dm_exec_requests req
INNER JOIN sys.dm_exec_sessions s ON req.session_id = s.session_id
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext

The result set contains:
s.host_name = terminal server
s.login_name = login
s.host_process_id = the process id on the Terminal Server which has issued the query

On the RDS server, open task manager | View | Select Columns
Tick the PID (Process Identifier) checkbox.
Sort tasks by PID to find the offending process.

Match PID on the terminal server =  s.host_process_id

Done.