I have a query in sql server 2008. That I want to either pass a value from the dropdownlist or IS NOT NULL (so it shows all of the values). What’s the best way to handle this? I know you can’t pass the string “IS NOT NULL” to the parameter. I’m a bit stuck on this one.
ASP.NET 3.5 and SQL Server 2008.
Assuming this is a stored procedure, say your parameter is called
@Param1, have the parameter set toNULLto indicateIS NOT NULL, as follows:Suggested by GSerg
Testing
ISNULL(@Param1, field1) = field1with the following:Computations are showing as 1 for each case. This appears to be a better solution than my original answer.