You cannot use = NULL , you have to use IS NULL
e.g
-- Create temporary table
CREATE TABLE #TempSP (eid INT IDENTITY, Value1 varchar(10))
-- Insert sample values
INSERT INTO #TempSP values ('Value1')
INSERT INTO #TempSP values ('Value2')
INSERT INTO #TempSP values ('Value3')
INSERT INTO #TempSP values (NULL)
-- Select query for check what's in table
SELECT * FROM #TempSP
-- Select query where value1 is NULL
SELECT * FROM #TempSP
WHERE value1 IS NULL -- WHERE value1 = NULL won't work
-- Delete rows where value1 is NULL
DELETE FROM #TempSP
WHERE Value1 IS NULL -- WHERE Value1 = NULL won't work
-- Select query for check what's in table
SELECT * FROM #TempSP
-- Drop temporary table
DROP TABLE #TempSP
No comments:
Post a Comment