I have 2 tables - each has a single row only. I want to update o1 and o2 columns on Table1 with the corresponding columns in Table2.
create table Table1(c1 int, c2 int, o1 int, o2 int)
create table Table2(o1 int, o2 int)
I have the following, which is horrible (but works).
update Table1
set o1 = (select o1 from Table2),
o2 = (select o2 from Table2)
Is there a better way?
You can use:
update table1
set o1 = t2.o1,
o2 = t2.o2
from table2 t2;