In SSRS 2008, how are parameters passed down to th

2019-10-03 16:15发布

问题:

In SSRS 2008, how are parameters passed down to the DatSet Query... or can they?

I have a simple question. I think this is pretty straight-forward. If necessary, I can include screen shots of what I mean.

Here is the basic format of the report. I have a SSRS report made on Visual Studio 2017. it has two DataSets. It has one Tablix and one Bar Chart that is loaded with from the DataSets. I have one Parameter defined for the report. The parameter a Date/Time data type set to allow nulls and I name it rundate. (I will use is in a data driven subscription, but for now that is beyond the scope of my question here)

Ffor each dataset, I have gone into the Datset Properties and added a parameter with a Parameter Name of rundate and Parameter Value [@rundate]. I think it would be great if I make this somehow a variable in the Query for the Dataset. I assume that this is exactly what this is supposed to be used for. How do I declare it in the SQL query.

I said that this was a pretty straight forward question. it should be easily answered and it will save time in digging around the internet for the answer. So far, all I have found is how to set up filters. This is not exactly the same sort of thing. But, if necessary, I guess I could resort to using filters but it will take some changes in the query. And it would be a mess.

https://reportsyouneed.com/ssrs-tip-put-parameters-in-your-query-not-your-filter/ offers a solution and this graphic on this page makes it look easy and I have tried something similar with my own WHERE clause: WHERE (InsertedDate > @rundate) But in preview, I get this

回答1:

In the query designer drag a dimension on top of your report. Chose an Operator and a Filter and check the checkbox by Parameters and BOOOM you have your parameter. If you go now into your report designer you find the parameter you just checked in the folder Parameters on the left navigation pane (on top of the Datasets folder). Now open the folder an right click on your parameter for the properties.

You can set now a default value. If not the report opens and waits until a users selects a value from the drop down selection. After the selection the parameter gets passed to the query and the query gets executed and the report rendered.