Ayman Ayman - 1 year ago 132
SQL Question

Select ISNULL is not returning replacement value

type is nvarchar.

The issue is when
is empty not returning


Select ISNULL(ContactPerson,'n/a') from [dbo].[Suppliers]

Answer Source

An empty string ('') and not the same thing as a null value. ISNULL() returns the replacement value only for an actual null value.

You can use NULLIF() to evaluate an empty string into a null value:

SELECT ISNULL(NULLIF(ContactPerson, ''), 'n/a') ...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download