Question : a generic way to capture the passed in parameter values in a SQL Stored Procedure

Hi Experts, for logging purposes I log every call that is made to a SP (and by whom and when). I use  this piece of code to get the name of the SP (CAST(OBJECT_NAME(@@PROCID) AS VARCHAR(255))).
Now I need also to know the values of passed in parameters. Does anybody know if there is a function/proc who gives me the information I'd like to have?
I designed this to do the job but as you can see I need to change this piece of code for every change of parameters. I'd like to have a small code snippet that works always.

        DECLARE @this AS VARCHAR(255)
        DECLARE @paramSet AS VARCHAR(255)
        SET @this = CAST(OBJECT_NAME(@@PROCID) AS VARCHAR(255))
        SET @paramSet = LEFT('@YYYYMM_From:' + COALESCE(@YYYYMM_From, '') + '|' + '@DomainID:' + CAST(@DomainID AS VARCHAR), 255)
        EXEC dbo.uspZTM_UspUsage @uspName = @this, @uspParamSet = @paramSet  


thanks leon

Answer : a generic way to capture the passed in parameter values in a SQL Stored Procedure

Sorry, you can get Proc name and parameter datatypes from system tables with code, but the actual values passed into the stored procedure are only captured in transaction logs and if you capture trace files but I do not think there is a generic way to get to those.  At least not that I have run accross.
Random Solutions  
 
programming4us programming4us