Trim Funtion in Dataset Stored Procedure Causes SSRS report Fail - sql

I have an SSRS report. It have multi valued parameters & a sub report. It runs fine until I changed the dataset for a parameter ( In both report). When I previewed the report it shows below error.
"one or more parameters were not specified for the subreport located
at /report".
I tried below steps to resolve the issue
1. Ensured parameter names are correct.
2. removed rdl.data file
3. Deleted the dataset and recreated it.
I tried to revoke the changes made in dataset & the report runs perfectly. The only change I have made in the dataset was the addtion of LTRIM(RTRIM)) Function in dataset query to remove the spaces between multi-value parameter.
The dataset query was like below
select Loan_no
From loan_header
where rowatatus = 'A'
I have changed it into
SELECT LTRIM(RTRIM(Loan_no)) As Loan_no
From loan_header
where rowatatus = 'A'
When I removed LTRIM(RTRIM) Function from the Dataset query, the report works fine. So, use of LTRIM(RTRIM) Function causes the Report failure.
What will be reason behind this? Anyone facing similar issue before?. Please help.

Related

Report Builder Report from Stored Procedure returns empty tablix rows

I have a relatively simple stored procedure which is just a select statement from 2 joined tables, and has a single parameter.
Running it in SSMS returns, for example, 6 rows.
In Report Builder, I created a dataset from this SP, and I added the fields manually in the Fields tab, using the same names as in the SP.
I pull the fields to a tablix - which returns empty rows, but interestingly - 6 empty rows. So it works fine in SSMS and Query Designer - but nothing when executing.
I have tried creating a brand new report from scratch, and I have checked for white font on white background - no result.
Any clues what could be the reason?
thanks in advance,
PS Value property:

SSRS conditional execution of dataset

I have two different datasets in SSRS report which gives different number of output fields.I have used this two data set into two different tables in report.
1) One table will display output at a time in execution based on condition.
Actually while running the report two datasets are executing the SP and it takes more time to display the output.
Requirement:
I need to execute the one dataset SP at time based on condition.Other Dataset SP should not Execute.
Example:
Dataset1 executes Sp1
Dataset2 executes Sp2
Table1 uses Sp1
Table2 uses Sp2
Normally while executing report Table1 will display output(Based on default parameter selection)
But SP1 and SP2 are executing on same time.so report takes more time to display output.
I need to execute 1 SP at a time based on condition.so that other dataset SP will not execute.
Step1:
First Create Dummy SP for Dataset .That SP should have same input parameters and same output fields as original SP1 but gives zero output rows.Do the same for SP2 for Dataset 2
Step2:
In Dataset properties select StoredProcedure Icon and in Fx column add below code
=IIF(Parameters!ManagerID.Value= -1,"SP1","DummySP")
Note: DummySP created should be same like SP1
Do the same for Dataset 2..and this works.
I have seen this answer, it's nice, but to create two SP's, it is sometimes very cumbersome. Sometimes the report uses a SP's many. This means that all SP's must be duplicated. And if you double the reports many... This means that they need to be maintained and improved throughout their lives.
Instead I have another solution:
Step 1: I create one SP, and use one of the parameters that already exists anyway.
Step 2: In the mapping of the DS\Report's parameters, instead of sending to DS the parameter sent to the report as it is, you can write an expression, which says that if I want to display the data of this SP I send the parameter sent to the report, and if I do not want to display this data, I will send different parameter , Which will cause the SP not to return data.
All this of course only if it is a procedure with parameters that allow the above. It is also possible to create a special parameter for this.
The following is a picture and example of an expression:
and the expression:
=IIf(Parameters!Display_xxx.Value=1,Parameters!yyy.Value,0)
You must control the visibility of tablix depends on the received parameter, in additional you can create parameters on both queries to control where execution to avoid the execution, like
Where #Condition = 1 AND ( Your WHERE )
As for that sack of performance, you don't want to run other SP at all, in this case, as per my experience, the best way is to modify your stored procs to add a new parameter based on what you are deciding what data set to call (means what data to pull).
So that, if the parameter says that the specific SP is not required, don't run the code in SP using IF-ELSE combo and return blank single row.
And then, on top of that, you can hide or show your tablix.
Hope that makes sense?
And if the column count and data types are same, you can always use an expression to decide what stored-proc to call.

Pentaho Execute SQL Statements variable conversion to null

I am using PDI to delete and insert some data from a DB. I have the following issue. I create two variables called START_DATE and END_DATE that are used to select the data that will be deleted from my DB. I am able to get them and run my transformation with no erors in the log file, but when I checked if data was deleted, I find it didn't. I send checked my "DeleteProcedure" step, and it says "Conversion error: null". I have tried different approached to take the variables and pass them as Strings, but I haven't been able to solve this issue. It cannot be a SQL mistake as I tested it with a constant and it works.
Any ideas? I attach some pics. Thanks!
As a documentation of the Execute SQL script says:
Note: When you have an issue, that the SQL is started at the initialization phase of the transformation and not for each row, make sure to check the option "Execute for each row" (see description below).
In your case it executes during the initialization phase of the transformation that's why it gets null values instead of ones from previous step.

ssrs one or more parameters required to run the report have not been specified

I'm having the error one or more parameters required to run the report have not been specified. The only thing is i've removed all but one parameter from my report and I have specified the value for that parameter. My guess is it's still looking for one of the parameter's i deleted from the report. How do I find that parameter value and get rid of it?
Replacing reports on the server often does weird things with the parameters on the server. The fix is to delete the report off the server and then deploy a fresh version.
One way this can happen is if you are using Shared Datasets and you pull in DataSets that your report is not using. Each report must define its own version of the parameters for each shared Dataset locally. So if you've included a Dataset as one of your data sources and you have not explicitly defined how this particular report will pass parameters to that Dataset, you'll get this error.

SSRS Text Query: Variable names must be unique within a query batch or stored procedure

I am developing an SSRS 2008 report, but instead of using stored procedures, I want to use all Text queries. This report was working with stored procedures, but when I changed this report to use same logic but via text queries, I got the following error:
An error occurred during local report processing
    Query execution failed for dataset 'BRSR_Totals'
        The variable name '#END_yEAR' has already been declared. Variable names must be unique within a query batch or stored procedure.
Operation cancelled by user.
The problem is that some of my datasets (text queries) re-use the same parameters and END_YEAR is one of these parameters. How do I make this report run correctly?
One area that you might want to check is case sensitivity. SSRS is case-sensitive when considering parameter names but T-SQL does not have that case sensitivity. Take another look at your code and make sure that all parameters are using the same case.
I just resolved a similar issue using a text query to populate a dataset. It worked in SQL Server Management Studio and it worked in the Query Designer within BIDS, but failed at runtime.
The issue turned out to be BIDS helpfully adding parameters to the Dataset that this query was referencing. Switching to the Parameters tab of the Dataset Properties showed that BIDS had duplicated the parameters I had already added earlier. Deleting the duplicates resolved my problem.
To respond to the suggestion that the logic be off-loaded into a stored procedure: in this case, the report is a custom report for a single customer. The query will only ever be used in this report and makes a few assumptions about the customer's configuration that should not be available globally
I also just fixed this same issue in one of my queries. I was using a text query and had datetime variables/parameters. SSRS added a second set into the parameters for the dataset properties. I deleted them and my query ran fine after that and my graph populated.
I ran into a similar issue on a report where I had declare a substantial number of parameters at the beginning that I didn't want the end user to see. The issue I had was I was using a comma at the beginning of the line, so I had:
DECLARE #Parameter VARCHAR(4) = 'text'
, #Parameter VARCHAR(4) = 'text2'
It worked just fine in SSMS, but when I ran it in Report Builder 3.0 it threw the error shown in this thread. I changed it to remove the comma and to restate DECLARE at the beginning of each line and it worked perfectly.
Check that you didn't declare it twice, once in the CREATE PROC statement you're creating and another in the actual code...I've seen this problem while testing changes to SP code.