• Sean,

    Here's the relevant code:

    ALTER TRIGGER [dbo].[tI_timCustItem] ON [dbo].[timCustItem] FOR INSERT AS

    /* Copyright (c) 1995-2011 Sage Software, Inc. All rights reserved. */

    BEGIN

    DECLARE @numrows INT,

    @nullcnt INT,

    @validcnt INT,

    @errno INT,

    @errmsg VARCHAR(255)

    SELECT @numrows = @@ROWCOUNT

    IF @numrows = 0

    RETURN

    SET NOCOUNT ON

    /* tciUnitMeasure R_2279 timCustItem ON CHILD INSERT RESTRICT */

    IF UPDATE(LastPriceUOMKey)

    BEGIN

    SELECT @validcnt = COUNT(*)

    FROM inserted, tciUnitMeasure WITH (NOLOCK)

    WHERE

    inserted.LastPriceUOMKey = tciUnitMeasure.UnitMeasKey

    SELECT @nullcnt = COUNT(*) FROM inserted WHERE

    inserted.LastPriceUOMKey IS NULL

    IF @validcnt + @nullcnt <> @numrows

    BEGIN

    SELECT @errno = 50002,

    @errmsg = 'Unable to add the timCustItem record because it is trying to reference a record in tciUnitMeasure that does not exist. Reference ID: (R_2279).'

    GOTO error

    END

    END

    Maybe my question should be isn't @@rowcount always one 1 in a trigger? You can see they use @numrows to do error checking? I guess it depends on the answer for @@rowcount.

    Thx.