isnull in where clause

I want to put the following code in my query where statement: isnull(criteria,'1=1').

the critieria will either be something like "Age < 18", "Age > 18", etc,  or NULL. I would love for there to be a SQL eval statement but there is not.  also i want to stay away from dynamic SQL.......is thre anything that i can do here or do i have to go to dynamic SQL?
LVL 1
DB_FuryAsked:
Who is Participating?
 
EvilPostItConnect With a Mentor Commented:
WHERE ISNULL(AGE,0)<18 AND ISNULL(AGE,0)>18
0
 
EvilPostItCommented:
you will need to use IS NULL not ISNULL.

ISNULL is a function that replaces a NULL values with a user specified one.
0
 
DB_FuryAuthor Commented:
yeah thats what i want becuase it the criteria field is null in the database i just want to put something that will always be true there so there isjust just a and with a blank in the syntax
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
DB_FuryAuthor Commented:
i cant put anything static becuase it could be null, it could be Age > 20. so hardcoding it wont work.  i wish there was a eval funcation
0
 
EvilPostItCommented:
If the age is 20 is wont be nulland will not therefore be replaced with 0. Only in the event of a null value will it be replaced.
0
 
DB_FuryAuthor Commented:
I was confused at first but now i understand.  thanks very much
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.