• SQLTestUser (6/17/2013)


    I have a column that has to be set with a certain value as A,B,C or D when a certain column has a value i.e. is not null. The columns are in various tables in the databases and the select is show below

    select A.decription, B.Decsription,C.Description,D.Decription

    from Audit A left join A.Id = B.ID

    left join on B.Id =C.ID

    left join on C.ID = D.ID

    and the column X in Audit table has to be updated with A,B,C,D as when if there is value in A.description the value for X will be B, when B.Description has value the value on X will be C, when c.description is there the value for X will be D

    how do i form a trigger that does this

    thanks

    So you want to update the value of column X in Audit when a value in either A, B, C, or D happens? You would need to create insert/update triggers on EACH of those tables.

    It seems to me that you might have better luck with a different approach than triggers. If you could explain the process, the business logic and provide a bit more details maybe somebody will have a better idea than triggers for this type of thing.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/