SQL Server NULL
October 6, 2007 — BeLeLearned something very important today about SQL NULL in this article from SQLServerCentral. Never knew there was so much behind a simple variable like NULL.
Here’s an excerpt from the article:
Four Rules in Handling NULLs:
- Use NULLs to indicate unknown/missing information only. Do not use NULLs in place of zeroes, zero-length strings or other “known” blank values. Update your NULLs with proper information as soon as possible.
- In ANSI SQL, NULL is not equal to anything, even other NULLs! Comparisons with NULL always result in UNKNOWN.
- Use SET ANSI_NULLS ON, and always use ANSI Standard SQL Syntax for NULLs. Straying from the standard can cause problems including portability issues, incompatibility with existing code and databases and returning incorrect results.
- The ANSI Standard COALESCE() and CASE syntaxes are preferred over ISNULL() or other proprietary syntax.
More about this later on. I need to get some sleep.