SSRS Running Datasets Multiple Times When I Change Parameter Values - sql-server

I'm seeing some weird behavior I can't quite figure out. I have a report with a bunch of parameters, none of them are cascading. A handful of the parameters are set to allow multi-select and the available/default values are retrieved from data sets that used stored procedures.
When I load a report every data set executes, which I expect. However, if I change a parameter value, such as the date for the date parameter, every data set executes again. Why is this?
What's compounding the situation is I have 2 copies of each parameter (Param1, Param1_Internal, Param2, Param2_Internal, etc.). I have it setup like that for formula's I'm using in the report to determine if the user selected 'Select All' for the multi-select parameters. So for example I'll have Param1 and Param1_Internal set from data set 1, Param2 and Param2_Internal set from data set 2. When I change an unrelated parameter data set 1 will execute twice, and then data set 2 executes twice.
Any suggestions to:
Get these data sets to run once each, even though one data set feeds available values for 2 parameters?
Stop the data sets from running every time I change an unrelated parameter?
I am currently on SQL Server 2016.
Thanks
Edit
So, I found the answer to part of my question. In some cases I am using an expression as the parameter value in the data set that calls my stored procedure. It looks like when you do this, SSRS will execute that data set every time you change any parameter value. I still am hoping someone will have advice on how to have a dataset run once in a situation where I have 2 parameters using it for default/available values.

You can cache data set results if they are in a shared dataset stored on the SSRS server. This way the first time you run it will execute the query, then the second will just pull from the cache:
https://learn.microsoft.com/en-us/sql/reporting-services/work-with-shared-datasets-web-portal#caching
Use with caution though, as if the backing values of your parameters change often you could get inconsistent results with your reporting.

You can stop the refresh on parameter change by making sure the below is set within the parameter properties:

Related

Run reports on all available parameter value

I set several parameters for a report created in SSDT (SQL Server Data Tools).
How can I run the report on all available parameter value and form a comprehensive
report with each case per session?
Thanks a lot.
E.g. a report called 'data growth' with parameters #database and #tablename. A serial of available names for these two parameters. I would like to compile the report with all cases.
You have two options.
1.
Manually include an additional All option into your parameter selections, either by adding a value in the menus or unioning the value if your parameter options are data driven, and set the source query to return all results when selected.
2.
Change your parameter to a multi-value parameter and change your source query to use where database in(#database) which will enable all combinations of your parameter to be selected, including all.

SSRS truncating parameter

I have an SSRS report that populates a parameter with a stored procedure. This query works as expected. When the parameter is used in running the report, the parameter is being truncated. I choose value ABCD, but the report returns values for ABC. The stored procedure I am passing the parameter to runs perfectly in SSMS and returns ABCD data. When I test the query in the query designer or I run the report, I get ABC data. How do I get SSRS to pass in the entire parameter?
Parameters are strings without a set length. There's nothing to truncate your values. Have you checked the values to make sure that the Value and Label are the same?
The label is what you see (ABCD) while the value is what is actually passed in the parameter. I don't know if that would be your problem if it works on your local machine though.
If that doesn't work you can try deleting the parameter and recreating it - it shouldn't work but has before.
I had something like this happen to me before, try going into the stored proc you have and creating an output table for your parameters results to go into that is constant, i.e.
declare #mytable table (returnval varchar(50))
make sure you make one column in the table for the results of your query you will return and make sure you make the data type a varchar with enough pace to hold any possible return selection values. Note: do not use nvarchar as I find this still sometimes truncates the values and cuts things off.
you will want to execute the query the same way for the proc you originally did but this time inserting the values into your temp table i.e.
insert into #mytable
select * from table.name
this will insert all values into your temp table, also this table now has a set value length for all return values that will not change, you could try and do this the same way with the original query by using a set length field for the table the problem is there are many factors that exist that can change this, here are a few examples.
If you have 2 select statements with a union to get results from both that you want to use for final results then each field may have a set length and data type that differs from the other, sql server will give the best data type in the results but when it sends the data over to ssrs it can interpret it differently as another length value unless set.
You may have multiple data types you are using in the return field and ssrs is getting confused which to use i.e. interger values, varchar, text, etc. this sort of reinforces the one above.
Also another possibility is it could be happening on the SSRS side of things and not the proc, but by doing this method you eliminate out one possible cause which is the stored proc.
Also, check in the configuration settings of your report on the back end and make sure that the return value is set from the query as it should be but also make sure that there is no setting specified for a return data type, this sometimes happens if at report design you create the report first and use a static parameter for testing to get the report created first and then you specify later the parameter is a list from a query result set which I have had happen as well.
Finally one good practice each time you make a change to something is to ensure that the report is being generated each time and not showing a cached version of the report which makes it look like nothing changes on the report each time. the way to do this is to close the report each time or when you run the report also try and make sure you hit the reload on the page after you run the report to force a reload to make sure you see the differences each time.
I think if you do all of this you will either find the issue or eliminate it or both as I have so many times.

Crystal Reports parameter sending NULL instead of chosen value

I have a CR 2008 report reading from SQL Server 2008 R2 that used to contain 3 parameters and worked like a champ. The business requested the addition of a fourth parameter. I added the variable to the stored procedure, tested and got the results I was looking for. I then created the parameter as a static list of values as we do not need all values available. I went to the record select expert and lined up my parameter with the appropriate database field. Ran the report, got an error on an incorrect amount of parameters. Refreshed the database; the report ran but returned no results. Checked my parameter values against the stored procedure. Once again, the stored procedure returned results. Went back to Crystal and viewed the query. Lo and behold, the query is sending in NULL for the new parameter even though a specific value was chosen on the prompt. I even went so far as view a tutorial on adding parameters to be sure I did it correctly. Anyone have any thoughts on why the parameter isn't being read properly?
I think you need to right click on Database fields from Field Explorer > Database expert > see this picture
that will surely work coz sometimes crystal reports stored procedure need to be reset or refresh to reflect any changes on the SQl code

SSRS Drop Down List Values

We have a report in SSRS that has drop down list parameters that are fed by a shared datasource and query.
If I use ReportViewer to view the report these work as expected.
However, I'm also using the SSRS web service to pull out the parameters and the available values. In this instance when drop downs are moved from a manually entered list to a query the available values list is empty.
I'm assuming the problem is because the web services simply gropes the RDL file and does not execute the queries attached to the parameters.
My question is, is there any way to have it do this or to get the available values?
After reading MSDN it seems the answer is to call GetReportParameters() and set ForRendering to true:
If ForRendering has a value of false, the parameter meta data returned represents the parameter data that is currently associated with the specified report. If any parameters values are based on a query and you are interested in returning the query-based parameters valid values list, you need to set ForRendering to true, In addition, for query based parameters, you need to ensure that you have passed in all of the credential information required to return the query parameters.

Crystal Reports using multiple results from a Stored Procedure

I have a stored proc in sql-server and one of the parameters it returns is a string with the query parameters. I display those query parameters at the top of the report. That works great if something is found, not so great if nothing was found.
We have tried returning two query results, one the data set that I will make the report from (which includes the query parameters), the other the query parameter string. Crystal appears to only see the first data set, and this very old discussion (http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=42462) says that is not something that will work. But that was over 5 years ago, and I'm hoping things have changed.
The problem, is if nothing is returned, the report is so blank that the person doesn't even know what query parameters they used. If they could see that they queried something that doesn't return any results, that would be useful.
So, if I have at the end of my stored proc:
SELECT * FROM [#ResultSet]
select #SearchCriteria as SearchCriteria
I'd like to be able to display the SearchCriteria even if there is nothing in the #ResultSet. Can it be done with this version of Crystal? Is there another way to do this?
Unless as stated by the first answer the results of one procedure have the same number of columns of another procedure (this includes type), if this is the case you can UNION the results or UNION ALL the results (if you want duplicates) to get ONE resultant set.
If the types or columns are not the same then you cannot do this. The only other option you can do is to merge all the relevant data into a temp table and then return the results from that temp table (SELECT * FROM #temp)
How are you currently able to display the parameters when results are found?
You haven't mentioned how you are using the Crystal Report in your environment.
Typically, I've done criteria display by passing the parameters to the Crystal Report as Report Parameters, and then using them in fields. This assumes you are calling it from a client application in some way.
Another option is to load the results into client datatables and binding to that as a datasource, it's certainly possible to handle the multiple result sets that way.

Resources