MSSQL ISNULL good function to replace null values

MSSQL has a nice function to replace null values conditinally

ISNULL(columnName, newValue)

This function requires two parameter columnName and new value to be replaced in place of null.

This function help me alot to solve the problem at database level instead at the coding level.

3 Responses to “MSSQL ISNULL good function to replace null values”

  1. Vijay Khambalkar Says:

    In mysql, we can use

    COALESCE(field,value)

    SELECT firstName, COALESCE(lastName, ‘Last Name Not Specified’) FROM info

  2. Diego Souza Says:

    Cool, exactly what I need.

    Thank You

  3. Greg Says:

    @Vijay Thanks for that comment. I was looking for an alternative for ISNULL since someone commented on one of my blog posts that I should use it. Unfortunately MySQL and MSSQL did the function differently and this is what I was looking for.

Leave a Reply