How to replace null with 0

Well worth considering using COALESCE instead of ISNULL. The differences are subtle, but can be significant.

ISNULL will use the data type of the first parameter, which can cause subtle changes to the use of the second parameter (when the first is NULL), and that can create a bug that is hard to find ...

COALESCE allows unlimited parameters - the first, non-NULL, is returned - and it determines the precedence of the data types of the parameters, rather than imposing the data type of the first one.

ISNULL is easier to type ... but a silly name as it is not descriptive of what it does. COALESCE is a monster to type ...

ISNULL is optimised out if the first parameter is defined as NOT NULL, which is definitely a benefit if ISNULL is used like confetti in code! but assuming this is used on columns which CAN be NULL :slight_smile: then there is no difference on that point alone.

People also mention that COALESCE is standards-compliant. I can't see that mattering to most people - I stopped supporting Oracle and Sybase nearly 20 years ago!