Trigger isn't working

  • Hi,

    I have a trigger, that works fine elsewhere but is not working at this location. At one point I put a print statement in the trigger just to see if it was firing. The message comes through, but the data is not being copied to the new table.

    USE [db name]
    GO
    /****** Object: Trigger [dbo].[Front Temps] Script Date: 10/16/2026 12:46:42 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO

    ALTER TRIGGER [dbo].[Front Temps]
    ON [db name].[dbo].
    after INSERT
    AS
    Begin
    SET NOCOUNT ON;

    INSERT INTO [db name].dbo.AlarmQueFront (CarId, ImageTime, FrontAlarmStatus, FrontAlarmTemp, Direction, TVImage, Images)
    SELECTi.[Car ID],
    i.[Image Time],
    i.[Front Image Alarm Status],
    i.[Front High Temp],
    i.[Direction Label],
    dbo.[TorpedoVision Data Images].[Front Jpeg],
    i.[Images]
    FROM INSERTED as i
    INNER JOIN dbo.[db table name ]
    on dbo.[db table name].ID = i.Images

    WHERE i.[Front Image Alarm Status] <> '0';

    END

     

  • 2 qs:

    1. Shouldn't you be joining on the ID = ID and not on ID = images?
    2. Is it possible that [Front Image Alarm Status] can be NULL?  If so, the WHERE condition will not be true and any row(s) with NULL will not be INSERTed.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

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

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