How to capture input parameters from within stored procedure (SQL Server 2005)?

Posted by Duncan on Stack Overflow See other posts from Stack Overflow or by Duncan
Published on 2010-05-17T21:55:06Z Indexed on 2010/05/17 22:00 UTC
Read the original article Hit count: 382

Filed under:
|
|
|
|

I would like to create a generic logging solution for my stored procedures, allowing me to log the values of input parameters. Currently I am doing this more or less by hand and I am very unhappy with this approach. Ideally, I would like to say something like the following:

"given my spid, what are my input parameters and their values?"

This is the same information exposed to me when I run SQL Profiler -- the stored procedure's name, all input params and all input VALUES are listed for me. How can I get my hands on these values from within a stored procedure?

Thanks; Duncan

© Stack Overflow or respective owner

Related posts about log

Related posts about stored