SQL Server 2008 R2: trigger after update <p>This is my first post so please bear with me. Here are the tables I'm working with and I'm only showing the relevant columns:</p> <p><strong>Movement</strong>:</p> <pre><code> id cnt_tare_weight chassis_tare_weight </code></pre> <p><strong>Stop</strong>:</p> <pre><code> movement_id order_id </code></pre> <p>For each movement record, there are 2 or more stop records. The way this works, is that we create an order and create the stops. The stops are grouped into movements. </p> <p>Here's some example data:</p> <p><strong>Movement</strong>:</p> <pre><code>id cnt_tare_weight chassis_tare_weight ------------------------------------------------- 1545257 4525.2 3652.2 1545258 null null </code></pre> <p><strong>Stop</strong>:</p> <pre><code>order_id movement_id ------------------------ 0933774 1545257 0933774 1545257 0933774 1545258 0933774 1545258 </code></pre> <p>Here's what I am trying to accomplish:</p> <p>When the <code>cnt_tare_weight</code> and/or <code>chassis_tare_weight</code> are updated in the <code>movement</code> record, I need to copy this data to all other movement records for that order. I want to use a trigger after update to do this. </p> <p>Here is what I've come up with but and I'm not sure it will work. I would like to see if what I'm wanting do is correct or if I'm missing something. </p> <p>Here's my SQL:</p> <pre><code>CREATE TRIGGER set_tare_weights ON movement AFTER UPDATE AS BEGIN SET NOCOUNT ON; DECLARE @movement_id AS INT; DECLARE @cnt_tare_weight AS DECIMAL(8,1); DECLARE @chz_tare_weight AS DECIMAL(8,1); DECLARE @order_id AS int; SELECT @movement_id = inserted.id FROM INSERTED IF update(cnt_tare_weight) BEGIN SET @cnt_tare_weight = 'Updated cnt_tare_weight' END IF update(chz_tare_weight) BEGIN SET @chz_tare_weight = 'Updated chz_tare_weight' END SELECT @order_id = order_id FROM stop WHERE movement_id = @movement_id UPDATE movement SET cnt_tare_weight = @cnt_tare_weight, chz_tare_weight = @chz_tare_weight WHERE @movement_id IN (SELECT DISTINCT movement_id FROM stop WHERE order_id = @order_id) AND id &lt;&gt; @movement_id END </code></pre> <p>I have never created a SQL Server trigger before. I'm not sure if this will work or if I need to do something more. Do I need to create a trigger that calls a stored procedure? Or will the above work? </p> <p>Thanks for any help!</p>