I have a query in a SQL Server 2008. It shows all the values that I want to pass a value from either the dropdownlist or not). What is the best way to handle this? I know that you can not give the string "IS NOT NULL" on the parameter. I'm stuck on this one
ASP.NET 3.5 and SQL Server 2008
Assume this is a stored procedure, say your parameter @ Param1
, set to NULL
, the parameter is set to IS NOT NULL
, as follows:
SELECT ... FROM ... WHERE (@ Param1 tap and field 1 is not zero) or (field 1 = @ param1))
Recommended by GSIG
test ISNULL (@ param1, field1) = field 1
with the following:
DECLARE @ test1 Nvarchar ( 10) = 'test ', @ Test2 nvarchar (10) = NULL; - or 'random' or 'test' SELECT 1 WHERE ISNULL (@ test2, test1) = @ test1;
Computation is being shown as 1 for each case. It seems to be a better solution than my original answer.
Comments
Post a Comment