I have two SQL Server tables. One table has four nvarchar(50) nullable columns and an ID column. The second table has two columns: ID, nvarchar(50) nullable column
I’m trying to insert the rows in the second table into the first table. How can I detect a null column in the first table and insert data from the second one into the null cell?
Ex:
Add from the second table
1 value3
to the first table
1 value1 value2 null null
so the resulting row is
1 value1 value2 value3 null
Ex2:
Add from the second table
2 value1
to the first table
nothing for ID 2
so the resulting row is
2 value1 null null null
Basically I need to update existing rows or create new ones depending on the ID of the second table rows.
Result: