Friday, May 25, 2007

String Concatenation in SQL Server

When using '+' to concatenate two string field in SQL server (e.g. a+b), if one of them is NULL, then the whole string will become NULL. There is one solution to solve it:

COALESCE(a,'') + COALESCE(b,'')

So if any of the field is NULL, it will evaluate as an empty string. That's it!

2 comments:

  1. You could also use the more intuitive:
    ISNULL(a, '') + ISNULL(b, '')

    My Blog: http://theplague.wordpress.com/

    ReplyDelete
  2. Sir, you are a genius, and saved me from panicking all over the coming weekend.

    Thank you!!

    ReplyDelete

Upgrade nodejs in conda (from v18 to v26)

If your conda env is nodejs v18, doing a conda install nodejs=26 is likely to create a lot of conflict. Consider remove those conflicting p...