Hi,
We are migrating a COBOL-DATACOME application to .Net COBOL and SQL Server using MicroFocus. I have been monitoring the queries via using DMVs and and traces. I notice an odd thing once in a while when using the most_recent_sql_handle. Sometimes I see a query show up that could not have been. In one case I noticed a biztalk connection creating a procedure. In another case a MicroFocus session executing COBOL created a procedure. In one case, I created the procedure the day before on a session that was closed.
I did not set the create procedure in the trace.
This leads me to think that the most_recent_sql_handle might not always be for the current session. Has anybody else seen this behavior?
I tried to recreate this in SSMS by creating a procedure in a session and closing it and opening a new session with the same session_id. I could not replicate the issue.
Here is one of the DMVs I used.
SELECT [sessions].session_id, [sessions].login_time, [sessions].host_name, [sessions].program_name, [sessions].host_process_id, [sessions].client_version, [sessions].client_interface_name, [sessions].login_name, [sessions].status, [sessions].last_request_start_time, [sessions].last_request_end_time, [sessions].transaction_isolation_level, [sessions].lock_timeout, [connections].connect_time, [connections].net_transport, [connections].protocol_type, [connections].auth_scheme, [connections].net_packet_size, [connections].client_net_address, [sql_text].text as [most_recent_sql_text] FROM sys.dm_exec_sessions [sessions] INNER JOIN sys.dm_exec_connections [connections] ON [connections].session_id = [sessions].session_id CROSS APPLY sys.dm_exec_sql_text([connections].most_recent_sql_handle) as [sql_text] FOR XML AUTO, BINARY BASE64, ROOT('most-recent-query-text'), type
Thanks
Randy in Marin