Home / Code Snippets / Blog article: T-SQL Return Empty String Instead Of Null

| RSS

T-SQL Return Empty String Instead Of Null

February 11th, 2009 | No Comments | Posted in Code Snippets

There are times when we want to return empty strings for column(s) which have NULL values. T-SQL makes this easy with ISNULL function. Two parameters for this function are:

  1. The column in question
  2. Replacement value

 

Here is an example query for Customers table in Northwind database. This query will select Region column from the table and return blank strings where it finds NULL.

SELECT ISNULL(Region,'') FROM Customers

 

Here is a partial screenshot of the resultset returned. You can see that the value for top rows is blank. These are actually NULL in database.

image

Leave a Reply 6452 views, 2 so far today |

Leave a Reply