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.
LVL 1
emi_sastraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
what is your issue? are your variable/fields nullable?
0
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.
0
Éric MoreauSenior .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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
emi_sastraAuthor Commented:
Hi Eric,

Thank very much for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.