Thanks for the reply. But, this does not solve my issues.
The reason the string has to be 'ABC' is because that is the row that is being pointed at by @Acct. You can see from my original statement that I need to be able to replicate the TextDesc of a specific row. The @tempTable tells me which rows in @textTable need to be updated or inserted. That is why row 6 is not touched.
I am trying to build a merge statement that will take the TextDesc pointed to by @Acct and replicating it to all accounts in TextTable that are in the @tempTable. And if it is not found, insert the row.
This is the code that I have written so far. It only does the update. 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.
MERGE into @TextTable T1
Select t.Acct a1, t3.textDesc, tt.Acct as newAcct
from @TextTable t
inner join @TextTable t3 on t3.Acct = @Acct
inner join @tempTable tt on tt.Acct = t.Acct
) T2 ON (T1.Acct = T2.A1)
WHEN MATCHED THEN
T1.textDesc = T2.TextDesc
WHEN NOT MATCHED THEN
INSERT (Acct, textDesc)
VALUES (T2.NewAcct, T2.TextDesc);
__________________________________________________________________________________________________________How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/