No value, parameter or table column, can ever be equal to NULL, regardless of what value is stored there (even NULL).
You need to test if a value IS NULL, as:
SELECT SomeField FROM SomeTable
WHERE SomeField = @someParam OR @someParam IS NULL
This could also be written equivalently as:
SELECT SomeField FROM SomeTable
WHERE SomeField = coalesce(@someParam, SomeField)
This works becuase if @someParam IS NULL, then the coalesce function will return the value of SomeField, thus testing a column value for equality with itself, which of course is always true.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com