Collections:
"IS NULL" - Testing NULL Values in SQL Server
How To Test NULL Values Properly in SQL Server Transact-SQL?
✍: FYIcenter.com
From previous tutorials, you learned that comparing expressions with NULL will always result NULL. So you can not use comparison operators to test if an expression represents a NULL value or not.
To test expressions for NULL values, you should use one of the following special operators:
expression IS NULL -- Returns TRUE if the expression is a NULL value expression IS NOT NULL -- Returns TRUE if the expression is not a NULL value
The tutorial script below shows you how to use IS NULL and IS NOT NULL:
IF 0 IS NULL PRINT 'TRUE' ELSE PRINT 'FALSE'; GO FALSE IF NULL IS NULL PRINT 'TRUE' ELSE PRINT 'FALSE'; GO TRUE IF 1+NULL IS NULL PRINT 'TRUE' ELSE PRINT 'FALSE'; GO TRUE IF 'NULL' IS NOT NULL PRINT 'TRUE' ELSE PRINT 'FALSE'; GO TRUE
⇒ ISNULL() - Replacing NULL Values in Expressions in SQL Server
⇐ NULL Values Involved in Boolean Operations in SQL Server
2017-02-03, 3293🔥, 0💬
Popular Posts:
How To Create a Dynamic Cursor with the DYNAMIC Option in SQL Server Transact-SQL? If the underlying...
How To Convert Characters to Numbers in Oracle? You can convert characters to numbers by using the T...
How To Escape Special Characters in SQL statements in MySQL? There are a number of special character...
How To View Data Files in the Current Database in Oracle? If you want to get a list of all tablespac...
How To Generate CREATE VIEW Script on an Existing View in SQL Server? If you want to know how an exi...