I have certain parameters in the crystal reports which would be passed directly into Stored procedure in sql . Parameter A has 5 values and I want to enable them for users so that when user opens up the report , he is able to select any number of parameters values in the drop down based on which report data would be filtered.
Please advise
For a parameter to select multiple values you need to enable the option allow multiple values to true.
As I know, in designing a report in Crystal Reports you can use a simple SELECT like this:
SELECT CAST(0 AS int) AS Id, CAST(0 AS varchar(0)) As Name
That will give you two fields like Id, Name and you can use them in your report.
Now, you can use that type of SELECT statement instead of running a stored procedure like EXEC SP1 #P1 = P1, #P2 = P2 just inside of your report designer and running that stored procedure when you are filling the Data-Set of your report.
Related
Using Sqlserver 2012.
Say I have a SSRS rdl report "P" that calls several subreports "S1", "S2".
Just wondering if it is possible to view (in a logfile etc), the parameters and values that P passes to S1 and S2 during report generation.
I know you can view the parameters and values passed to the parent report P in views like ExecutionLog3, but couldn't find any logging of the subreports' parameters.
A work around will be to display the parameter values in the subreports themselves, but this is not ideal. The reports themselves run ok .. the parameters are wanted for diagnostic purposes.
I would suggest adding the logging process to the start of your main dataset in each subreport, that way it will fire only when the subreport is called.
In other words, the dataset for "S1" might look something like...
INSERT INTO dbo.MyLogTable (SubReportName, Parm1, Parm2, ActionDate)
VALUES ('S1', #p1, #p2, GetDate())
{Your original dataset SQL here}
If you parameters are multi-valued then you may have to do some manipulation first but you get the idea I hope.
You could also improve this by using the ID of the subreport from the report server catalogue in case you ever want to join this back to the execution logs.
I work with CRM 2015.
When I try create report with multiply-values parameter, I can not split it on list id.
I tried many ways to do it like:
ALTER PROCEDURE [dbo].[pn_rep_LoadResources]
(#Stage NVARCHAR(1000))
WHERE(stage.new_stageid IN (SELECT Value FROM dbo.FnSplit(#Stage,',')))
WHERE(stage.new_stageid IN (SELECT Value FROM dbo.Split(#Stage,',')))
WHERE(stage.new_stageid IN (SELECT Value FROM dbo.Split(#Stage,',')))
WHERE(stage.fn_GetGuidsFromString IN (SELECT Value FROM dbo.Split(#Stage)))
And other, but nothing works.
Have anyone problem like this?
I have a report that must be populated with data based on a #Flag parameter. The report is pulling from one stored procedure which calls data from 2 separate tables. For instance, EQ.Equipment, EQ.Address, EQ.City, EQ.State,... and FL.Equipment, FL.Address, FL.City, FL.State,...
I have added a Flag parameter that if #Flag = 'E' it will pull from the EQ SELECT statement and if #Flag = 'F' it will pull from the FL SELECT statement. Is this possible? If so, how can I implement this?
Try something like this (using the actual name of the tables):
IF (#PARAM = 'E')
BEGIN
select * from EQ_table
END
ELSE
select * from FL_table
In the dataset properties map #PARAM to the parameter created in your report.
Let me know if this helps you.
I'm fairly new at stored procedures and using them with SSRS.
I want to create a simple SSRS report using a Stored Procedure with a parameter allowing multiple values (results from a separate Procedure)
I have 2 simple stored procedures as Follows.
Create Procedure WO
#STARTDATE datetime, #ENDDATE datetime, #DISTRICT varchar(25)
AS
SELECT A.WO, A.CUST, A.DISTRICT, A.COMPL_DATE
FROM WORK_ORDERS A
WHERE A.COMPL_DATE between (#STARTDATE) and (#ENDDATE)
and A.DISTRICT_NAME in (#DISTRICT)
Create Procedure DISTRICT
AS
SELECT B.DISTRICT_NAME
FROM DISTRICTS B
In my SSRS report, I'm reporting the WO Procedure using the result(s) from the DISTRICT procedure using a "DISTRICT" parameter with the available values from the DISTRICT procedure (ALLOWING MULTIPLE VALUES). Also I've used the DISTRICT Parameter in the Parameters of the WO procedure.
This works when selecting one District, but not when I select multiple districts. Anyone out there willing to help?
If I'm not mistaken, the problem is handling the string parameter #district - presumably, SSRS is passing something that looks like "N,S,E,W", assuming 4 districts were selected - the stored proc would then come out as: ...A.District_Name in ('N,S,E,W')... which would only return a value if there were a district name 'N,S,E,W'. So, I think you need to split the incoming value and reassemble it as 'N','S','E','W'. Unfortunately, there's no SPLIT function in SQL Server, so you either have to write a UDF (there are several posts available) or make a CLR call.
Here's a clever (and untested) thought - try Replace(#District,',',''',''') (I think I got the quotes right...)
Currently have three subreports, one main report.
Main report has two parameters - SELECTDATE and EMP_ID. Main report sends Order_Nbr to all subreports.
All subreports work perfectly when I only select 1 Employee and 1 date, but if I choose multiple values it blows up.
SQL has the column as an INT. I have both parameters in main report and subreport, SELECTDATE is set as Text with Multiple Values, and EMP_ID is set to Integer with Multiple Values. My queries has my date IN (#SELECTDATE) and emp_id IN (#EMP_ID).
It obviously sends the correct information to the subreports because it works, but I would like it to work with more values being passed. Love the current ability to check and uncheck employees and end of month dates, like it currently is set using the IN function in my query.
Make the Parameters on your sub report non-multivalue, remove any 'Available values' set.
Pass the multivalue parameter from you parent report as a string using the join method
=Join(Parameters!Emp_ID,",")
The EMP_ID parameter will be set to a comma delimited list, which is what a multivalue parameter sends to the query
I'm not sure how this works with text queries, but it works with stored procedures.
If the sub report is also used as a stand alone report you will need to add a new parameter to allow the user to send parameter values to #Emp_Id from a parameter the user can set
I guess you have not set the parameter in the sub report as Multi Select. If you have set the parameter in the sub report as multi select, then you could just send the parameter from the main report to the sub report as it is. See more at here
I used the following solution, which works in SSRS2016. This also works with text parameters.
Like suggested above, pass the parameter as a string to the subreport by JOINing the values.
Join(Parameters!EmpID, ",")
In your subreport, accept the parameter as text.
In the SQL of your subreport, use the string_split function of SQL 2016 to return a table of the values and simply join it to your main query. So basically if your parameter is named "EmpID_Multi" do
... JOIN (SELECT value FROM string_split ( #EmpID_Multi, ",")) mv ON mv.value= ...
Note: You might consider pulling the values into a temporary table for SQL optimization (sometimes the optimizer does funny things...).