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, 1616🔥, 0💬
Popular Posts:
How To Get Year, Month and Day Out of DATETIME Values in SQL Server Transact-SQL? You can use DATEPA...
How To Convert Binary Strings into Integers in SQL Server Transact-SQL? Binary strings and integers ...
How to execute statements in loops in SQL Server Transact-SQL? How to use WHILE ... loops? You can u...
How To Drop a Stored Procedure in Oracle? If there is an existing stored procedure and you don't wan...
Why I Can Not Enter 0.001 Second in DATETIME values in SQL Server Transact-SQL? If you enter millise...