This post originated from an RSS feed registered with .NET Buzz
by Anand M.
Original Post: How to use Nulls..
Feed Title: .NET From India
Feed URL: http://www.dotnetindia.com/index.rss
Feed Description: Your daily dose of .NET From India
Came upon this interesting article called the Four rules for Nulls. Some of the places where the books online is not exactly correct is pointed out in this article. The most helpful aspect of this article is that it puts together in a single place the best practices to be used in working with NULLs.
Rule #1: 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.
Rule #2: In ANSI SQL, NULL is not equal to anything, even other NULLs! Comparisons with NULL always result in UNKNOWN.
Rule #3: 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.
Rule #4: The ANSI Standard COALESCE() and CASE syntaxes are preferred over ISNULL() or other proprietary syntax.