SSRS - Passing parameter to run stored procedure - sql-server

I have set up a report in SSRS which drills through to a 2nd report. The data in the second report is a stored procedure that has a parameter declared, as in:
CREATE PROCEDURE [dbo].[Procedure] (#Parameter VARCHAR(max)) AS.....
In the first report I have set up the Action on the text box properties to run the second report using the relevant parameter from the first report.
I am designing this in Visual Studio and when I 'Preview' the report in here it works correctly and the drillthrough passes through the parameter as intended. However when I deploy this onto our server and try to view the report using Internet Explorer the drill through doesn't work, I get an error saying that the parameter is read-only and cannot be modified.
From reading other posts relating to this online people have mentioned changing the parameter visibility to 'Visible' however this hasn't worked on mine.
Has anyone else experienced anything similar to this before?
Thanks.

This seems to be a common problem when passing a parameter to a subreport. Have you seen this solution? http://saiabhilash.blogspot.nl/2012/05/report-parameter-is-read-only-and.html

Related

Can I alter the "Execute Procedure" pop up window in SSMS?

My boss would like to see an example of the data type when executing stored procedures.
When you execute a stored procedure, a popup window appears showing parameter,data type, output parameter, pass null value and value. For example, if the parameter and data type is a date he wants to be able to visually see on that screen what format the date should be entered "YYYY-MM-DD", "YYYY-DD-MM", etc.
If the parameter was customer name and the data type is nvarchar(128) he wants to know what that would look like. Ideally, I would like to insert a new column on this popup that shows an example of the intended format. I'm just not sure if it's possible.
I've searched on google and stack overflow for SQL user interface changes, SQL
formatting tools and altering stored procedures. So far I've seen are articles from Microsoft on Graphical Query Designer User Interfaces, Apex SQL Refractor, and posts on this site that are not quite what I'm looking for.
I'm not sure my boss would want me to share my company's code online.
I've only been working with SQL for a few months so I'm not super familiar with how to alter things, only how to query and organize the results so any help would be appreciated. Below is what the popup window looks like currently.

Passing a parameter from main report to drillthrough SQL Server Report Builder 3.0

I am trying to restrict what users can view based on the branch that they work in. I have it working on my main report but I want to pass the branch parameter from my main report to a drillthrough subreport. How can I do this in Report Builder 3.0? Thank you.
You can pass the parameter via the url.
Example:
http://myrshost/ReportServer?/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2&ReportMonth=3&ReportYear=2008
Here we're passing the report parameter ReportMonth the value 3 and ReportYear with 2008
An alternative to using a URL, you'd need the same parameters in both reports.
Go to the properties of where you want the drill-through to occur.
Go to Action
Select 'Go to Report', specify the report directory (this can be flat files or via the report server). Think this can also be a URL but I am not certain.
Select 'Add'. In the Name field, you want to put the parameter name of the parameter in the drill-through report, in the 'Value' field you want to enter the parameter of the report that you're currently in.
If you don't want the user changing this parameter, in the drill-through report, you can simply hide this parameter in the drill-through report.
This is by far the easiest way of doing what you require I believe. Hope this helps if you're still struggling.

SSRS 2014 issue with dataset after deployment

My report is running without a sweat on my dev environment. I was a happy man.
When deployed on another server, I have the following issue (see below) (less happy now )
The error is:
The variable name '#choix_de_l_adresse' has already been declared.
Variable names must be unique within a query batch or stored
procedure.
I've checked the parameters for the dataset adresse1. Nothing substantial came out (see image below).
I thought it may be related to a case issue with my sql (see below) but nothing striking jumps off
DECLARE #choix_de_l_adresse VARCHAR(38)
SELECT JohnJack.Siren,
CASE WHEN JohnJack.Adresse1_Eco IS NULL
THEN '' WHEN JohnJack.Adresse1_Post IS NULL
THEN '' WHEN (JohnJack.Adresse1_Eco IS NOT NULL OR JohnJack.Adresse1_Post IS NOT NULL)
AND #choix_de_l_adresse = 'Adresse Postale'
THEN Adresse1_Post
ELSE Adresse1_Eco END AS adresse1
FROM JohnJack
The only workaround I've been able to find out is to delete the dataset and to recreate it from scratch.
Update: When I'm using ssrs query builder to run the query batch, it is running fine
Do you think using a stored procedure would help? I read somewhere that text was not a good fit and when possible, a stored procedure would be better.
Have you seen the following issue and were you be able to fix it without deleting and recreating your dataset? If the answer is yes, how did you do it?
I managed to solve my issue.
I created a stored procedure, put my sql code inside and ... voilĂ  ! all the rows I was looking for, were retrieved

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 Subreport not seing values in only one dataset

I'm working on a series of reports which need to be shown in two languages so I've created a common header that I planned on embedding into the content of each report. I have two data sets, one that looks up a set of strings in English or French (depending on a parameter passed to the report), and another with numerical data.
The original header worked fine and when I extracted it into a separate report it also runs fine. I am just passing the name of the report to the subreport. When I run the main report, it seems that the values in my string dataset are all null (I've tried all of them) yet if I try data from my numerical dataset, the fields have values and get displayed as the title.
If I also insert a text field with the same expression to display the report title after the subreport, it works fine but the title still does not get passed to the subreport.
I cannot make any sense of why this would be happening, anyone have a clue?
I'm using Report Builder 2.0 and SQL Server 2008.
Thanks!
Alright, so I worked around this issue by simply passing my parameters on down to the subreports and letting them call the stored procs again. Not ideal since I now have to call that one stored proc 3 times but it probably won't be noticed.
I tried several other work arounds and received errors like rsAggregateInCalculatedFieldExpression, so my best guess is that this was caused by attempting to use an aggregate function (First) where it is not allowed but the error was never shown.

Resources