I have a script that updates multiple columns. However, I want to ensure that the columns in the UPDATE list are only updated when they are NULL. Here is the script:
DECLARE @blank nvarchar (255) = '';
UPDATE Table
SET
Column1 = @blank,
Column2 = @blank,
Column3 = @blank
WHERE
Column1 IS NULL OR
Column2 IS NULL OR
Column3 IS NULL
This will not work, because all the columns will be updated even if only Column1 is null.
I need to only update column values if that value is NULL.