Tuesday, May 2, 2017

Dealing NULL and Empty value in SQL

Dealing with null data become hectic.I need to put '-' when the column is NULL  but when I am digging in to data I found there are empty data as well
so if you put IS NULL check it will not work so there is a hack

 ISNULL((CASE WHEN  datalength(COLUMN_NAME)=0 THEN (NULL) ELSE COLUMN_NAME  END), '-')

No comments:

Post a Comment