Collections:
NULL Values Involved in Comparison Operations in SQL Server
What Happens If NULL Values Are Involved in Comparison Operations in SQL Server Transact-SQL?
✍: FYIcenter.com
If NULL values are involved in comparison operations, the result will be Boolean NULL values. This behavior is very interesting because you would expect a comparison operation returns only one of the two values: TRUE and FALSE. But SQL Server may return you a third value: NULL.
The tutorial script below proves that "1>NULL" is not returning TRUE or FALSE. It is returning a third value, NULL:
IF 1>NULL PRINT '1>NULL is returning TRUE' ELSE PRINT '1>NULL is not returning TRUE' GO 1>NULL is not returning TRUE IF NOT 1>NULL PRINT '1>NULL is returning FALSE' ELSE PRINT '1>NULL is not returning FALSE' GO 1>NULL is not returning FALSE
Another test proves that "'FYI'=NULL" is not returning TRUE or FALSE. It is returning a third value, NULL:
IF 'FYI'=NULL PRINT '''FYI''=NULL returns TRUE' ELSE PRINT '''FYI''=NULL does not return TRUE' GO 'FYI'=NULL does not return TRUE IF NOT 'FYI'=NULL PRINT '''FYI''=NULL returns FALSE' ELSE PRINT '''FYI''=NULL does not return FALSE' GO 'FYI'=NULL does not return FALSE
⇒ NULL Values Involved in Boolean Operations in SQL Server
⇐ NULL Values Involved in Bitwise Operations in SQL Server
2017-02-03, 2316🔥, 0💬
Popular Posts:
Is PL/SQL Language Case Sensitive in Oracle? PL/SQL language is not case sensitive: Reserved words a...
How To Generate Random Numbers with the RAND() Function in SQL Server Transact-SQL? Random numbers a...
How to connect SQL Server Management Studio Express to SQL Server 2005 Express in SQL Server? Once y...
Where to find SQL Server Transact-SQL language references? You can find SQL Server Transact-SQL lang...
Is SQL Server Transact-SQL case sensitive? No. Transact-SQL is not case sensitive. Like the standard...