Trigger syntax error

  • I receive a syntax error " Incorrect syntax near 'QuoteId' " when creating this trigger. I assume if have something to do with having two "FROM" statements. However, the first FROM is inside separate SELECT.

    Any help will be appreciated.

    Doug

    Create Trigger trgInsertSalesForce

    on dbo.CustomerQuote

    AFTER Insert

    as

    begin

    Update CustomerQuote

    set SalesForceId = (select SalesForce.SalesForceId

    FROM SalesForce INNER JOIN

    TKOUser ON SalesForce.SalesForceName = TKOUser.UserName inner join

    CustomerQuote on CustomerQuote.UserId = TkoUser.UserId)

    From Inserted

    where Inserted.QuoteId = CustomerQuote.QuoteId

  • Quick suggestion

    😎

    Create Trigger trgInsertSalesForce

    on dbo.CustomerQuote

    AFTER Insert

    as

    begin

    Update CQ

    set CQ.SalesForceId = (select

    SalesForce.SalesForceId

    FROM SalesForce

    INNER JOIN

    TKOUser ON SalesForce.SalesForceName = TKOUser.UserName

    inner join CustomerQuote on CustomerQuote.UserId = TkoUser.UserId)

    From Inserted I

    INNER JOIN CustomerQuote CQ

    ON I.QuoteId = CQ.QuoteId;

    Without further information, one is limited to guessing;-)

  • Thanks for the suggestion Eirikur, but that still produces a syntax error as shown below. I then removed the semicolon and then the syntax error moved the " near 'QuoteId' "

    Doug

  • doug-583247 (4/26/2015)


    Thanks for the suggestion Eirikur, but that still produces a syntax error as shown below. I then removed the semicolon and then the syntax error moved the " near 'QuoteId' "

    Doug

    My bad, forgot the END

    😎

    Create Trigger trgInsertSalesForce

    on dbo.CustomerQuote

    AFTER Insert

    as

    BEGIN

    Update CQ

    set CQ.SalesForceId = (select

    SalesForce.SalesForceId

    FROM SalesForce

    INNER JOIN

    TKOUser ON SalesForce.SalesForceName = TKOUser.UserName

    inner join CustomerQuote on CustomerQuote.UserId = TkoUser.UserId)

    From Inserted I

    INNER JOIN CustomerQuote CQ

    ON I.QuoteId = CQ.QuoteId;

    END

Viewing 4 posts - 1 through 3 (of 3 total)

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