Results 1 to 5 of 5

Thread: Trigger Fails

  1. #1
    Join Date
    Jul 2002
    Posts
    2

    Exclamation Unanswered: Trigger Fails

    This Trigger fail.

    CREATE TRIGGER SINC_ORIGEN_NV ON [dbo].[Referencias]
    FOR INSERT,UPDATE
    AS
    UPDATE [dbo].[Referencias] SET OrigenNV = 1 WHERE dbo.referencias.[N] = inserted.[N]

    Inserted table dont exist. I dont know what to do. Thaks

  2. #2
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    you either need to use the "IN" predicate, not a bad idea, or join the "referencias" table to the "inserted" table.
    Paul Young
    (Knowledge is power! Get some!)

  3. #3
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Try this one... Good luck!

    CREATE TRIGGER SINC_ORIGEN_NV ON [dbo].[Referencias]
    FOR INSERT,UPDATE
    AS
    UPDATE [dbo].[Referencias]
    SET OrigenNV = 1
    WHERE dbo.referencias.[N] in (select N from inserted)

  4. #4
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    You need to include INSERTED in your FROM clause

    Code:
    CREATE TRIGGER SINC_ORIGEN_NV ON [dbo].[Referencias] 
    FOR INSERT,UPDATE 
    AS 
    UPDATE R
    SET OrigenNV = 1 
    FROM Referencias R,
         Inserted   I
    WHERE R.[N] = I.[N]
    MCDBA

  5. #5
    Join Date
    Jul 2002
    Posts
    2

    Cool

    Ok! Now it works!

    Thanxs to everybody!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •