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.

Advertisements

3 Responses to MSSQL ISNULL good function to replace null values

  1. 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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: