I have two tables on a Microsoft SQL Server 2016 Instance.
Table#1
deviceid | string1 | Date |
---|---|---|
1 | 1234ALT | 30.06.24 |
2 | 1234ALT | 30.06.24 |
Table#2
deviceid | string1 | Date |
---|---|---|
1 | ||
2 |
Table#2 has a lot more columns but for my usecase I only need these 3
Now I need a query that matches the deviceid from table1 to table2 and inserts the values for string1 and date from table1 into table2
The origin of table1 is an Excel file I already inserted in to a new table to make it easier to import. If I would try
update table2
set string1 = (select string1
from table1
where table2.deviceid = table1.deviceid)
where table2.deviceid = table1.deviceid
and do the same for the date column would this work?