Want to work with us? We're on the lookout for a Magento Developer.

We're hiring

NULL Values in MS SQL

Web Bureau

15 January 2013 by Web Bureau

Couple of things I have come across recently with NULL values:

CONCATENATING when one field has NULL value

This can happen when you are building up a number of fields to compare against a search string.  Either COALESCE or ISNULL will do the trick.

WHERE COALESCE(p.field1,'') + COALESCE(p.field2,'') + COALESCE(p.field3,'') LIKE @SearchText

SQL NOT IN constraint and NULL values


COALESCE(field1,'') + (CASE WHEN field2 IS NULL THEN '' ELSE ' | ' + field2 END)

Grow your businessStart a project with us today.