Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

SSRS - Optional Report Parameter -ISSUES with query

$
0
0

I have a SSRS reports with the following parameters configured as: 

-@prmID  ---  I configured this parameter to "Allow blank value" because the user does not necessarily needs to enter a value
-@prmReviewer -- Allows multiple values
-@prmState  -- Allows multiple values
-@prmJobT -- Allows multiple values

My query looks like:

;WITH cteTemp(
   SELECT  Last
          ,First
          ,email
          ,ID
          ,Reviewer
          ,State
          ,JobTitle
   FROM (JOINS)
   Where State IN (@prmState)
   AND Reviewer IN (@prmReviewer)
   AND Jobtitle IN (@prmJobT)
   AND ID = @prmID
               )

SELECT DISTINCT Last, First, email
FROM cteTEmp


**The query above works perfectly fine when the user enters a value for @prmID 

What do I need to do for my query to continue working when the user leaves the @prmID blank?

-If the user enters @prmID then the query should do: 

Where State IN (@prmState)
   AND Reviewer IN (@prmReviewer)
   AND Jobtitle IN (@prmJobT)
   AND ID = @prmID

If the user leaves blank @prmID I want the query to evaluate:

Where State IN (@prmState)
   AND Reviewer IN (@prmReviewer)
   AND Jobtitle IN (@prmJobT)

Do I need to have an IF/ELSE statement inside my cteTemp to evaluate ISNULL(@prmID)?


-Alan


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>