Skip to Main Content
Learn T-SQL Querying
book

Learn T-SQL Querying

by Pedro Lopes, Pam Lahoud
May 2019
Intermediate to advanced content levelIntermediate to advanced
484 pages
11h 23m
English
Packt Publishing
Content preview from Learn T-SQL Querying

NULL means unknown

In the context of a database, if a column is set to NULL, it effectively means that value is unknown. If we compare any other value with NULL, the result of that comparison is also unknown. In other words, a value can never be equal to NULL as NULL is the absence of a value. This means the ColumnValue = NULL expression will never evaluate to true or false; even if ColumnValue is in fact NULL, it will always evaluate to unknown. To detect whether a column value is NULL, we must use the IS NULL or IS NOT NULL special expressions rather than = or <>.

This handling of NULL is not unique to SQL Server, it is based on the ANSI standard handling of NULL values.

Having NULL values in our database is not an anti-pattern in and of ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn T-SQL Querying - Second Edition

Learn T-SQL Querying - Second Edition

Pedro Lopes, Pam Lahoud
SQL Server T-SQL Recipes, Fourth Edition

SQL Server T-SQL Recipes, Fourth Edition

Jason Brimhall, Jonathan Gennick, Wayne Sheffield

Publisher Resources

ISBN: 9781789348811Supplemental Content