Filter Data Tenor

Hi All,

I have a SP with filter, if @TENOR =  0 then filter data with Tenor 0, else Filter Data with Tenor > 0.

I try below :

 AND H.Tenor =
 IIF(@TENOR <> 0 AND H.Tenor > 0, H.Tenor, 0)

What's wrong with this ?

Thank you.
Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
Your syntax seems fine to me (if you are using SQL 2012 or better).

if your H.Tenor can be null, you can use:
AND isnull(H.Tenor,0) =  IIF(@TENOR <> 0 AND isnull(H.Tenor, 0) > 0, H.Tenor, 0)

Open in new window

Éric MoreauSenior .Net ConsultantCommented:
what is your issue? are your variable/fields nullable?
emi_sastraAuthor Commented:
Hi Eric,

- what is your issue?
Not check to data yet.
Just want to make sure it is the correct way to do it.

- are your variable/fields nullable?
How to overcome this ?

Thank you.
emi_sastraAuthor Commented:
Hi Eric,

Thank very much for your help.
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.