I need to update the column on Table_1
, and then SET
the value which select from Table_2
UPDATE top(3) a
SET col_1 = col_2_From_Table_2
// Problem here, select col_2 from Table_2 and update into col_1
FROM Table_1
Table_1
ID | col_1
-------------
11 | null
11 | null
11 | null
11 | null
11 | null
Table_2
col_2
-----
AA
BB
CC
Expected Result of Table_1 (Update top 3 records which select form Table_2
)
ID | col_1
----------
11 | AA
11 | BB
11 | CC
11 | null
11 | null
Best Answer
So really these tables aren't related in any way at all. Assuming you want each row in table 2 assigned to a row in table 1, here's one arbitrary way to do it:
If you have other columns you want to order by, you can add them. If you only want three rows and there are more than three rows in table 2, add: