Assume a table definition in SQL Server as follows:
CREATE TABLE MyTable (
Id UNIQUEIDENTIFIER NULL,
Info VARCHAR(MAX)
)
And a query:
DECLARE @id UNIQUEIDENTIFIER
DECLARE @info VARCHAR(MAX)
IF @id IS NOT NULL
BEGIN
SELECT @info = Info
FROM MyTable
WHERE Id = @id
END
In that case, the Visual Studio static code analyzer produces the following error:
Warning : SR0007 : Microsoft.Performance : Nullable columns can cause final results to be evaluated as NULL for the predicate.
I don't see the problem here. The error is related to performance; MSDN says I should use ISNULL() -- but an equals comparison against NULL is always false, right? Am I missing something, or is the warning just wrong?