Oracle NVL equivalent on MS SQL

I have been an Oracle DB person for quite a while until my new job where we are running DB2 and MS SQL for the moment. Now, in Oracle, the NVL() function is a quick shortcut for series of nasty CASE THEN ELSE statements. Since the data am dealing with here is a little messy, I needed plenty of such.To make matters worse, SQL is the only common denominator for me between Oracle and MS SQL (as far as Mr. Olowe is concerned).

Anyway, after banging my head on the table exactly 1001 times, I finally discovered that ISNULL(element_to_check,value_if_null) does the same thing. I gleefully went over my previous codes and yanked the sonafab***h CASE statements out.

Knowledge is really power.

To read more on ISNULL for MS SQL, head over to http://msdn.microsoft.com/en-us/library/ms184325.aspx

Post a Comment

Your email is never published nor shared. Required fields are marked *