Capture/log input data to stored procedure?

  • Is there a way to log the input data that is used for a stored procedure in SQL Server 2005? I would assume it's possible, but it might require an external tool or possibly with the SQL Server Profiler, but I'm not sure as I've never used it before.

    Thank you for any help in advance! 🙂

  • Are you looking for an automated way to do this? If so, the only thing I know of would be to build a server side trace to capture it. You would need to filter to just the procedures you are interested in and only capture batch completed events.

    The other option is to edit every procedure and include auditing in the procedure.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Thank you, Jeffrey. Right after I submitted my post I went to check out SQL Server Profiler and found that it can do exactly what I was needing. Pretty cool tool, I might add. A little limited in some way, but it serves my purposes and for that I'm definitely grateful. I'm sorry to have bothered you guys with this.

  • No bother - glad you were able to figure it out. Be careful, if you are going to be running this long term you will be much better off using a server-side trace. Once you have everything configured/setup in Profiler - you can save that by going to File | Export | Script Trace Definition.

    Once you have that script, edit the script and specify the file (without the extension) and execute it. That script will start the trace and log the entries to the file you specified.

    Now, you can use the function fn_trace_gettable to read the file. Example:

    SELECT * FROM fn_trace_gettable('filename specified above', default);

    You can get more information on this in books online.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 4 posts - 1 through 4 (of 4 total)

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