T-SQL: select rows not equal to a value, including nulls
t-sql
Solution
Try checking for NULL explicitly:
SELECT TOP 30 col1, col2, ..., coln
FROM Mails
WHERE (assignedByTeam <> 'team01' OR assignedByTeam IS NULL)
Problem
How do I select rows which don't equal a value and also include nulls in the returned data? I've tried: ``` SET ANSI_NULLS OFF SELECT TOP 30 FROM Mails WHERE assignedByTeam <> 'team01' ``` I want to return rows which don't have 'team01' in column assignedByTeam but I also want results containing nulls. Unfortunately, the above code doesn't work (doesn't return the nulls). I'm using MS SQL Server 2008 Express.