I have a database table with many columns. Is there sql that will update records in that table where all or only specific columns are handled in such a way that if NULL is passed for any column value that the existing value not be changed?
Currently I can use solutions like these
UPDATE table
SET column1 = COALESCE(@param1, column1),
column2 = COALESCE(@param2, column2),
...
WHERE id = @id
or
UPDATE table
set column1 = isnull(@param1,column1),
column2 = isnull(@param2,column2)
They both works well, though sometimes I want to explicitly save null in any column and I can't do it with the above solutions. How?