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
Â
2017-02-03, 1182👍, 0💬
Popular Posts:
How To Change the Password for Your Own User Account in MySQL? If you want to change the password of...
What Are Bitwise Operations in SQL Server Transact-SQL? Bitwise operations are binary operations per...
How To Run SQL Commands in SQL*Plus in Oracle? If you want to run a SQL command in SQL*Plus, you nee...
How To Get the Definition of a Stored Procedure Back in SQL Server Transact-SQL? If you want get the...
How To Calculate Age in Days, Hours and Minutes in SQL Server Transact-SQL? On many Web sites, news ...