Given the following table and data
CREATE TABLE #temps
(
id int,
name varchar(max)
)
INSERT INTO #temps VALUES (1, 'foo')
INSERT INTO #temps VALUES (2, '')
INSERT INTO #temps VALUES (3, NULL)
I want to select all rows that don't have foo
in the name
column.
SELECT * FROM #temps
WHERE name <> 'foo'
DROP TABLE #temps
Why does this return only row #2? The name in row #3 is NOT foo
and should be returned.
My solution would be
SELECT * FROM #temps
WHERE ISNULL(name, '') <> 'foo'
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