Hi,@SPWGUT
Have you heard of the use of merge into? It seems like a simple question. It's my word. I'm willing to do it.
MERGE INTO YourTable T
USING (
SELECT id, col1, col2
FROM other_table
WHERE tsql = 'MAD'
) S
ON T.id = S.id
WHEN MATCHED THEN
UPDATE
SET col1 = S.col1,
col2 = S.col2;
As for cte , it doesn't mean that there is something special about it . Better call it, untested but should do what you want, hope this helps you.here is the code:
WITH CTE
AS (SELECT T1.Col1,
T2.Col1 AS _Col1,
T1.Col2,
T2.Col2 AS _Col2
FROM T1
JOIN T2
ON T1.id = T2.id
WHERE EXISTS(SELECT T1.Col1,
T1.Col2
EXCEPT
SELECT T2.Col1,
T2.Col2))
UPDATE CTE
SET Col1 = _Col1,
Col2 = _Col2;
As a reminder, if you want to learn merge usage, please refer to the documentation.
Bert Zhou