Link to home
Start Free TrialLog in
Avatar of Robb Hill
Robb HillFlag for United States of America

asked on

Stored proc - Parameter issue

I have an SSRS combo box that will pass 1 of 3 values to my stored proc.

'ALL'
'NATIVE'
'LINKED'


I need the report to do the following based on one of these 3 options being picked.

If the parameter Native is picked...then it should be be equal to the columns value in the report of Native.
the same if Linked is chosen..

If All is chosen it should return anything in this column...which could be "Native" , "Linked", '' , NULL

Please help me build the where clause to handle this.

Here is what I have ..but its not working.


(((@NativeLinked = 'Native' or @NativeLinked= 'Linked') and t2.[Native/Linked] = @NativeLinked) or ((@NativeLinked = 'All') and t2.[Native/Linked] is null or  @NativeLinked = 'Native' or @NativeLinked= 'Linked'))
SOLUTION
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robb Hill

ASKER

i cannot use the nullif function....using comptibility mode 100
let me rephrase for clarity..

I have a parameter that will pass one of three values  ( Linked, All, or Native"

All does not exists....All simply means both Linked and Native...but I also have to include blanks and nulls in the All as well so all records get returned on the All selection..  Another way to say is All means just ignore the parameter.

Chosing linked or native should return only rows where the column is equal to that.
select @NativeLinked = case when @NativeLinked = 'All' then null else @NativeLinked end;
This is a where clause...

And  When the parameter passed is 'All' is should be every value...including nulls  

This select you made reads to me when its all then make it null...else use the other value.

It should be when its all use null and all values...else use one or the other.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I believe that it has been taken care of in suggested WHERE clause. If you believe not, please give scenario.
hmmmmm..interesting...trying that
Nitin..not following your use of numbers in your where clause
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
We are trying to arriving at the equality here and nothing more. Just to confuse people further, I even used to use different numbers everytime I write such case statements, for example:

where 99 = case .....then 99 else 98 end.

And typically developer keeps concentrating on 99 and 98 where they shouldn't. Hope you got it.
Thanks for the detailed solution....testing the solution worked....thanks im on an all nighter deadline:)
Welcome. Glad to help as always.