Testing Triggers

I hate testing triggers.  It's a pain to figure out what's going on inside the code.  Especially when you're dealing with the inserted and deleted tables.  There are two great tricks I always forget.  The first is the SQL Debugger built into Query Analyzer.  Create a stored procedure to make the database change that fires the trigger.  Call this procedure in the debugger and it will step through the procedure AND the trigger(s).  The second trick is that Profiler can show you each statement inside a stored procedure that executes.  And this also shows each statement that executes inside a trigger.  Not as informative as the debugger but still pretty handy.

Show Comments