Wednesday, November 09, 2005

 

Comparing NULL in T-SQL

Books on Line (BOL) taught us how to compare NULL in T-SQL statements. Here is the excerpt from BOL about NULL comparison.

“To determine if an expression is NULL, use IS NULL or IS NOT NULL rather than comparison operators (such as = or !=). Comparison operators return UNKNOWN if either or both arguments are NULL.”

But, Query Builder tool which comes with SQL Server is not smart enough when it deals with NULL. ;-) The Query Builder does not know to change =NULL to IS NULL when performing NULL comparisons. So, when we build query with query builder, change "=NULL" to "IS NULL" in the query manually.

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?