Multiplication operator in a trigger

  • G'day guys,

    I have a service that writes to a database, one of the tables the service writes to holds calibration values for physical devices.

    I need to multiply one of these calibration values by two, on insert, so for example if the service inserts calibration factor A as 3.3 I need to multiply by 2 on insert, so what is inserted is calibration factor A = 6.6

    If anyone could put me on the right tracks here it would be greatly appreciated.

  • Update: I figured this one out, this is what I did, for anyone searching for a similar solution:

    CREATE TRIGGER [trgname]

    ON [tblname]

    AFTER INSERT

    AS

    BEGIN

    UPDATE tblname

    SET columnname = 2 * inserted.columnname

    FROM inserted

    WHERE tablename.ID = inserted.ID

    END

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

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