T-SQL reference › NULL vs blank
NULL vs empty string in SQL Server
NULL is unknown. A blank is a value. An empty-string check is false for NULL. Reports that should say No phone need to catch both.
Treat both as missing
SELECT customer_id, first_name,
CASE WHEN phone IS NULL OR LTRIM(RTRIM(phone)) = '' THEN 'No phone'
ELSE phone END AS phone
FROM Customers;
Or NULLIF(LTRIM(RTRIM(phone)), '') which turns a blank into NULL, then ISNULL.
= NULL
Never true. Use IS NULL. Same as on the ISNULL page.
Try it on Harbour & Co
Becky Ashworth (Support) needs this now: “Support is phoning customers. Blank phone numbers confuse the team. Can it say No phone instead?” Write the query, run it, send the results. Free.
Take the ticket →Learn it on a real ticket
Monday is free on WorkSQL. A colleague’s ticket lands, you write the T-SQL, we mark it. No videos. Five minutes.
Clock in free See Monday’s tickets