• UPDATE t1

    SET Id = COALESCE(t2a.Id,t2b.Id,t2c.Id)

    FROM Table1 t1

    LEFT OUTER JOIN Table2 t2a ON t2a.Acc = t1.AccType1

    LEFT OUTER JOIN Table2 t2b ON t2b.Acc = t1.AccType2

    LEFT OUTER JOIN Table2 t2c ON t2c.Acc = t1.AccType3

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537