I have a table with two DATETIME columns.
One of them is never NULL, but one of them is sometimes NULL.
I need to write a query which will set all the NULL rows
I would do it this way:
UPDATE YourTable SET B = COALESCE(B, A);
COALESCE is a function that returns its first non-null argument.
In this example, if B on a given row is not null, the update is a no-op.
If B is null, the COALESCE skips it and uses A instead.