Procedure Parameters & Values at Run time

  • Hello experts, I was wondering if this is possible. I will like to capture the list of parameters for a stored proc and it's the values of the stored proc when the stored proc is been executed or is executing. I want to capture is data out side of the stored proc not within. Is this possible? If it is how? Does any one have sample code? Any suggestions how this can be done. Thanks in advance

  • I think the best way to do this would be with Profiler. If you use the template SQLProfilerTSQL_Replay it will capture the actual calls to the SP along with the parameters used. You can then save this out as a file or into a table for later.

     

    Hope this helps!




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

  • I will experiment with that, but is there any other way to do this without Profiler say by writing a procedure? or Function? Thanks

  • None that I know of off the top of my head. Besides, why reinvent the wheel? Profiler is very efficient and works very well!




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

  • I guess my next question is, can you setup a profiler template and execute it from a Stored Proc on demand (as needed only) rather than scheduling it to run for ever? 

  • Yes you can. Look at the system stored procedures that start with sp_trace_.

    IE: sp_trace_create, sp_trace_generateevent, sp_trace_setstatus...




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply