• LinksUp (2/16/2014)


    I suspect that the inner join is preventing row 3 from the @tempTable from being part of the result set, thus the code for WHEN NOT MATCHED never executes.

    That's exactly right; you have a spurious (meaningless coulum in your source table (T2) and don't have all the required rows. If you just generate useful columns it's easier to generate the required rowset. Replace your using clause by

    USING (

    select tt.Acct a1, t3.textDesc

    from @tempTable tt cross join @TextTable t3 where t3.Acct=@Acct

    ) T2 ON (T1.Acct = T2.A1)

    (I've use the same aliases t1, t2, t3 as you did to make it clear what is happening).

    Tom