La principal diferencia entre los dos es que IFNULL la función toma dos argumentos y devuelve el primero si no es NULL o el segundo si el primero es NULL .
COALESCE La función puede tomar dos o más parámetros y devuelve el primer parámetro no NULL, o NULL si todos los parámetros son nulos, por ejemplo:
SELECT IFNULL('some value', 'some other value');
-> returns 'some value'
SELECT IFNULL(NULL,'some other value');
-> returns 'some other value'
SELECT COALESCE(NULL, 'some other value');
-> returns 'some other value' - equivalent of the IFNULL function
SELECT COALESCE(NULL, 'some value', 'some other value');
-> returns 'some value'
SELECT COALESCE(NULL, NULL, NULL, NULL, 'first non-null value');
-> returns 'first non-null value'
ACTUALIZACIÓN: MSSQL hace una verificación más estricta de tipos y parámetros. Además, no tiene IFNULL función pero en su lugar ISNULL función, que necesita saber los tipos de los argumentos. Por lo tanto:
SELECT ISNULL(NULL, NULL);
-> results in an error
SELECT ISNULL(NULL, CAST(NULL as VARCHAR));
-> returns NULL
También COALESCE la función en MSSQL requiere que al menos un parámetro no sea nulo, por lo tanto:
SELECT COALESCE(NULL, NULL, NULL, NULL, NULL);
-> results in an error
SELECT COALESCE(NULL, NULL, NULL, NULL, 'first non-null value');
-> returns 'first non-null value'