How to get Connection ID in Extended Stored Procedure?
-
Friday, February 24, 2012 8:50 PM
I know Extended Stored Procedures are yesterday's news, but they still have their place.
Does anyone know how to get the current Connection ID from inside an Extended Stored Procedure?
Thanks.
- Edited by Neil.W Friday, February 24, 2012 8:52 PM
All Replies
-
Monday, February 27, 2012 3:03 AMModerator
Hi Neil,
You could use a combination of Session ID, Host Name ,Login Name and login_time to get a distinct connection id from sys.dm_exec_connections and sys.dm_exec_sessions.
This information can be obtained from
select a.session_id, a.login_time, a.host_name, a.login_name, a.login_time,a.session_id,b.connection_id from sys.dm_exec_sessions a , sys.dm_exec_connections b where a.session_id=b.session_id
Best Regards,
Peja
Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.- Marked As Answer by Peja TaoModerator Monday, March 05, 2012 1:30 AM

