I have a nullable varchar and even when it is null, I want my select to return an empty string and not null. That is
SELECT FIRST, LAST
FROM CUSTOMER
What I want is if FIRST
is null, I want the return to be ""
You can also use
SELECT COALESCE(FIRST, ''), LAST FROM CUSTOMER
This has the advantage of being more portable (COALESCE is part of the SQL Standard, ISNULL isn't)
You can also use an arbitrary number of arguments, like
SELECT COALESCE(FIRST, SECOND, THIRD, '')...
And COALESCE will use the first non-null value encountered
SELECT isnull(FIRST,'') AS FIRST, LAST FROM CUSTOMER
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With