This is a follow up of the question.
How do I UPDATE from a SELECT in SQL Server?
If I use the query in question 2334712, How would I insert 'ABC', 'BCD' or 'DEF' in the Table_A?
I tried but I can't use the ORDER BY
clause in query.
Query result should be ABC (If ascending order), or DEF (If descending order), or based on a key on another column, say B3
.
UPDATE
Table_A
SET
Table_A.A2 = Table_B.B2
FROM
Table_A
INNER JOIN Table_B
ON Table_A.A1 = Table_B.B1
WHERE
Table_A.A1 < 10
Table_A:
A1 A2
1 (desired result: can insert 'ABC' or 'DEF' based on my choice)
2
Table_B:
B1 B2 B3
1 ABC 1
1 BCD 2
1 DEF 3
2 GHI 4