Custom Event Handler

I need to capture a trace history of each invocation of each stored procedure, function, and DML command that SQL Server runs. Hopefully, this would include the server name, instance name, database name, database connection ID, user name, stored procedure name, stored procedure parameter list and values, start time, and stop time. Within each stored procedure, I also need to capture history on each DML command, including the command text, record count, and again start and stop time. If stored procedures or functions are nested, I also need a way of correlating child executions to the parent that called them.

I know I could do this by adding code to each sp or function, but that seems laborious and, especially over time, likely to erode. So I'd much rather write an event handler (preferably in C#) that would gain control after each sp, function, and DML command and stores the required information in a set of tables.

Is there any way of doing this? I presume there is, because SQL Server Profiler capture the same information, but I want to capture and save the information in background (without Query Analyzer running) and then query it later.

July 2nd, 2013 4:13pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics