I have a query like this:
SELECT DISTINCT
[F_Exhibitor_Name]
FROM
[V_ExhibitorLocation]
WHERE
F_ExhibitionCode ='10996'
AND
[F_Exhibitor_Name] IS NOT NULL
ORDER BY
F_Exhibitor_Name
My first line is blank, which causes an error in the code. My current result set looks like this:
In SQL Server, a null
and an empty string (''
) are not the same. If you which to exclude both, you should explicitly check for both:
SELECT DISTINCT [F_Exhibitor_Name]
FROM [V_ExhibitorLocation]
WHERE [F_ExhibitionCode] = '10996' AND
[F_Exhibitor_Name] IS NOT NULL AND
[F_Exhibitor_Name] <> ''
ORDER BY [F_Exhibitor_Name]
I can suggest a trick for mixing IS NOT NULL
AND <> ''
like this:
SELECT DISTINCT
F_Exhibitor_Name
FROM
V_ExhibitorLocation
WHERE
F_ExhibitionCode = '10996'
AND
F_Exhibitor_Name > '' --or ISNULL(F_Exhibitor_Name, '') <> ''
ORDER BY
F_Exhibitor_Name
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