Monday, September 22, 2008

COALESCE

Returns the first nonnull expression among its arguments.

COALESCE ( expression [ ,...n ] )

If all arguments are NULL, COALESCE returns NULL.

ISNULL() accepts exactly two parameters. If you want to take the first non-NULL among more than two values, you will need to nest your ISNULL() statements.
COALESCE(), on the other hand, can take multiple inputs.

SQL Server views a column created by COALESCE() as nullable, whereas one using ISNULL() is not.

Many uses of Coalesce
http://www.mssqltips.com/tip.asp?tip=1521