T-SQL: Manipulating NULL value


NULL values are special in SQL Server. They are not blanks or zeroes, but “Nothing” as they don’t take space in the database (table columns) and in the memory (variables). VBA uses the same word (Nothing) for NULL. The usage of NULL is a great discussion between developers and DBAs and it is a matter of preference. I use the NULL value in my database architecture and development.

Create a test database

Any declared variable has a value of NULL before a value is SET.
When assigning a value to a variable, I use =, <> (!=) and when I manipulate the variable, I use IS NULL, IS NOT NULL.

1

SELECT FirstName = John, WHERE LastName doesn’t start with ‘Smith’

2

Filtering NULL and blank (empty string)

3

Clean up test database

Keep it simple :-)

Leave a comment

Your email address will not be published. Required fields are marked *