Getting the value from a column during a trigger After a test completes (on a SQL 2008R2 system), the system updates a row in the TestRun table to include an end time. I am creating a trigger that will take action after that update, and do some post-test analysis for me.

Right now it's very simple.

BEGIN

    SET NOCOUNT ON;
    DECLARE @errCount Int
    @errCount = exec USF_NumofErrors @RunID = '124'

END
GO


However I would like to have that integer replaced with a variable that is the RunID of the row updated (which is causing the trigger to fire).

How can I do that?
Triggers in SQL Server are fired once per set, not per row (like Oracle), so you need to build triggers that handle this.

In all triggers, you have two special tables called inserted and deleted, that contain  a virtual "mirror" of the entire table row(s) after and before the action that triggered it, respectively.

A word of warning: triggers should be small and very light-weight. In your case, running a cursor over your log rows and executing a stored procedure for each row can cause you locking mayhem and slow performance. (Triggers run synchronously, in the same transaction as the original DML statement.)

I would write your solution not in a trigger, but as a separate stored procedure and run it on-demand.