I want to replace all values which has a NULL value with the the value in another column on the same row.
I have tried different sql statements without any success.
Regards
I want to replace all values which has a NULL value with the the value in another column on the same row.
I have tried different sql statements without any success.
Regards
If you want to update, do something like this:
update t set col1 = col2
where col1 is null
If you just want to do selection, use most databases support coalesce:
select coalesce(col1, col2) from t;
col2 is null itselfIf you want to Update the value from same column
UPDATE A
SET A.Col1 = A.Col2
From TableA A
Where A.Col1 IS NULL
If you want to update the value from Other table then Try this:
Update A
SET A.Column1 = B.Column1
From TableA A
INNER JOIN TableB B
ON A.SomeID = B.SameID
WHERE A.Column1 IS NULL
You can update the value by using join and update query.