FireDAC – MSSQL – Stored Proc context details?

FireDAC – MSSQL – Stored Proc context details?

Without adding parameters to the stored procedure, is it possible to pass / push more process context info than what MSSQL already has in sp_who? http://msdn.microsoft.com/en-us/library/ms174313.aspx

In particular: client app processid and thread id

Any optional connection parameter or similar?

   

2 thoughts on “FireDAC – MSSQL – Stored Proc context details?


  1. 1. select HOST_ID()   returns the PID of the client on the machine that is executing the SQL or T-SQL code.  


    2. FDConnection.Params.Values[‘ApplicationName’] := AppId + ‘ pid=’ + IntToStr(GetCurrentProcessId)+’;tid=’ + IntToStr(GetCurrentThreadId);


    sort of works, but requires that you init the connection per thread.  The name is visible in SELECT program_name FROM sys.dm_exec_sessions  among other places.

Leave a Reply