Friday, July 01, 2005

Usage Rules for NULL

A useful article Four rules on Nulls. Was a good read.

The article starts with explaining what NULL actually is and puts forth four rules on NULL usage.

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.

Via: Anand

1 comment:

Anonymous said...

Hi Mahalakshmi,

Glad you enjoyed it :) Here's a preview link to the follow-up (scheduled for publication later this month): NULL vs NULL