• domleg (4/9/2014)


    Lowell,

    I get the following error:

    Msg 207, Level 16, State 1, Procedure TR_PrmMilkVisitExample1, Line 20

    Invalid column name 'LacId'.

    Msg 207, Level 16, State 1, Procedure TR_PrmMilkVisitExample1, Line 20

    Invalid column name 'LacId'.

    When trying your first example.... These are 2 different tables not joined by any keys... PrmMilkVisit and RemLaction are different tables and I only want to run the script when there is a change to the RemLactation table for the columns dryoffdate or calvingdate.

    The error referrs to the fact that LacID is not the real name of your PK, but since you didn't provide that Lowell had to guess.

    As far as the logic for your trigger you want to look for all zero values in the PrmMilkVisit table when there is a change in the RemLaction table? But these tables have no way of joining to each other? If it isn't ever valid to have all zeros (for the columns mentioned) then why do you only want to run it when the two columns change in a different table that we can't join to?



    Microsoft Certified Master - SQL Server 2008
    Follow me on twitter: @keith_tate

    Forum Etiquette: How to post data/code on a forum to get the best help[/url]