suppose i am calling a Stored Procedure and sending some params. the Stored Procedure will update a table and a trigger is there for that table. so when Stored Procedure update table then i want which user is updating the table but i am not using sql server user name rather i will send user names to SP who will update the table. so before update i can store that user name in local temp table and query that local temp table from trigger to get that user name. i hope it is possible but i want to other good option to achieve this job. so please share idea. thanks
suppose i am calling a Stored Procedure and sending some params. the Stored Procedure
Share
You can encode the user name in the procedure into the session using SET CONTEXT_INFO
This can be read in the trigger by CONTEXT_INFO
This is concurrency safe: each session/call is isolated from any other.
And no need for a temp table or such.