Multi Value Parameter in SSRS -Values are showing NUll when selected - sql-server

I tried using
Where Location IN(#Location)
in my storedprocedure
In SSRS
i used =join(Parameters!Location.Value,",")
When i select all values the result is null
The value is in string format
Eg: 'XXXX,YY','yyy,mm'

You need to change your Sql stored procedure code so that it could recognize the comma separated values being passed from SSRS.
One way would be using table-value function that can split a comma-delimited string back out into a mini table - link
Once done the code in your stored procedure should be like this -
WHERE Location IN (SELECT Param FROM dbo.fn_MVParam(#Location,','))

Related

how to pass multiple integer parameter value in SSRS

I have a stored procedure that has structure like this:
ALTER PROCEDURE dbo.GetUserFullName
(#NoteStoreType INT = NULL)
AS
SELECT DISTINCT dbo.tblUsers.LastName + ', ' + dbo.tblUsers.FirstName as UnderwriterName
FROM tblUsers
WHERE tblUsers.Type = COALESCE(#NoteStoreType, tblNoteStore.Type )
In my SSRS report I want to say if #NoteStoreType= NULL then select ALL NoteStoreTypes, if not then use #NoteStoreType that user will select.
If I allow multiple values then it gives me an error converting datatype int to string.
Can I do that in SSRS without changing anything in my stored procedure?
The multiple parameters that are selected will get passed to stored proc as a string. You will need to change stored proc to split this string. Also if you want to pass null you will need to check the allow null value.

SSRS - Format Output of Dataset for Input of Parameter

I have a dataset that is driven by a stored procedure requiring a parameter. The parameter is DATETIME but I am unable to present in that way in the report because DateTime's show as a calendar and I need a dropdown of values.
Alas, I have a dataset that drives the choices for the parameter called BaselineDate. The issue comes down to the way that SSRS formats the DateTime value for the parameter then passes as VARCHAR to the stored procedure. The VARCHAR value is in the wrong format.
SSRS
Expected Value
2016-04-07 13:01:19.173
Update
Per #Marco Bong's suggestions I have converted the dataset that is driving the Parameter options to the proper format. Unfortunately, SSRS I passing the parameter value as null.
Below is what is a debug table I created. I am simply inserting the value of the parameter into this table. As you can see SSRS is passing null to the stored procedure as NULL which in theory should be impossible as the parameter is set to not allow nulls. Any ideas?
select CONVERT(NVARCHAR,getdate(),21) as dtValue
//output will be ===> 2016-04-13 08:32:16.697
Update
If you want to use that selected value in another dataset (which execute your store prod), you may need to do this:
Then you can use this #param1 in your query.
Either where something = #param or set #baselineDate = #param

Execute stored procedure with multiple parameter values

I have a simple stored procedure, which executes in base of one input parameter. But I have to execute it about 100 times because of different parameters (parameter is int)Is there any other way except of inputing parameter values one by one? I mean something like #parameter in (value 1, value 2, .....value n).Thanks a lot.
This is the procedure:
ALTER PROCEDURE procname
#parameter AS BIGINT
AS
DELETE FROM tbl1 WHERE id = #parameter
DELETE FROM tbl2 WHERE tbl2_field=#parameter
DELETE FROM tbl3 WHERE tbl3_field=#parameter
DELETE FROM tbl4 WHERE tbl4_field=#parameter
1) make the parameter optional
2) when parameter is provided, use it to filter the results
3) when parameter is null, return all results, grouped on the field represented by the parameter.
Such as :
Select EmpNum, EmpNameFull, DeptName, HireDate
From Employee
Where DeptName = paramDeptName
or paramDeptName IS NULL
Order
By DeptName
, EmpNameFull
You could pass an array to the stored procedure. This is already answered with different database versions and multiple solutions on Stack Overflow here:
How to pass an array into a SQL Server stored procedure
and here
Passing an array of parameters to a stored procedure
Another solution could be to send the parameter comma separated and split it in T-SQL and loop through the values, How to split a comma separated string and loop its values in SQL Server (string parameter would be needed).

Execute sql stored procedure with array input from kettle table input step

I am having a sql stored procedure that takes 2 inputs and returns a resultset based on the given input.
I am using the input1 in sql IN clause like,
WHERE myCol IN(#input1)
when executing the store procedure from kettle table input step,
If i give a single value for the input1, it works fine.
EXEC sp_procedureName #input1='07423', #input2='2014-09-02'
If i give multiple values like below, it results empty resultset.
EXEC sp_procedureName #input1='07423,07022,07033', #input2='2014-09-02'
How can i pass multiple values as a parameter to my procedure.
the transformation will execute the procedure and insert the result set into another table using table output step.
What you need to do inside your stored procedure is split the comma delimited list of numbers into a list of single values in rows. Once you have this you can use WHERE myCol IN(SELECT v FROM #r), or use an INNER JOIN instead of IN. One point you might have to watch for is that you have leading zeros - if you want to keep those you will need to use strings instead of integers.
There are lots of articles around on the subject of splitting delimited values into rows, you could start here.

Sql Server Reporting Services Must Declare the scalar variable #param

I have a Sql Server reporting services project. I have a dataset query called Total where I select certain data based on a parameter:
select ...
from ...
group by ...
having prop_id = #PropID
Now to populate a list of multiple values for this parameter, I have a dataset query called AllProps that selects all possible prop_id's:
select prop_id from proposal
order by prop_id
Now in the Report Data Pane I select the parameter properties from #PropID and fill out the forms as follows:
Under General I have,
Name: PropID
Data type: Text
(I select "Allow multiple values")
Under Available values I have,
Get values from a query
Dataset: AllProps
Value Fields: prop_id
label field: prop_id
Under Default Values I have,
Get values from a query
Dataset: AllProps
Valuefield: prop_id
When I click the preview tab to see my report I get the following error:
An error occurred during local report processing. An error has occurred during report processing. Query execution failed for dataset 'Total'.
MUST DECLARE THE SCALAR VARIABLE '#PropID'.
Where did I go wrong? What is scalar variable in SSRS and how is it properly used?
Thanks
The query which you have written needs to be corrected .Since you have selected multiple values you need to use in clause .
Select col1,col2....
from TableName
where prop_id in (#PropID)
in stored procedure you can directly pass the parameter and split the values using a function inside stored procedure.
if parameter is directly passed to a sql query instead of stored procedure, then concatenate the parameter values using a join and pass to datasetenter image description here

Resources