SSRS 2005 - How to pass multi value parameter to a stored procedure from a BIDS report?
Hi all
I am trying to pass a multi value parameter from a BIDS/SSRS 2005 report to a stored procedure. The report works fine if I only select one item in the multi value parameter. However, if I run the report and select two or more values in the multi parameter,
nothing gets returned. What should I be doing to make this work?
My SP starts as follows:
---Delete existing SP
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('BFWD_Depn'))
DROP Proc BFWD_Depn
go
--- Create Stored proc
--- Calculation of Brought Forward depreciation
create proc [dbo].[BFWD_Depn]
@CompanyID nvarchar (4), @AssetGroup nvarchar (10),@Date datetime
AS
begin
set nocount on
set dateformat dmy
declare @month int, @year int, @day int
--- set @Date = '15/12/2011'
set @month = MONTH(@Date)
set @year = YEAR(@Date)
set @day = DAY(@Date)
if ((@year<=2010) or (@year=2011 and @month<=10))
begin
...
There is more code after the ..., but I dont *think* it is relevant. Presumably the issue is how I have set out the above code? Can someone have a look and let me know if I have made an obvious error? The problem parameter is @AssetGroup. There are 4 available
values in the BIDS report to select from. If I select one of any of them, the report works fine and the data returned is as expected. If I select more than one, nothing gets returned.
Thanks
Naz
April 14th, 2011 4:53am
try by using below sample query
DECLARE @AssetGroup NVARCHAR(MAX)
SET @AssetGroup = Char(44) + @AssetGroup + Char(44)
SELECT * FROM tablename
WHERE @AssetGroup Like '%,' + AssetGroup + ',%'
Rajesh Jonnalagadda http://www.ggktech.com
Free Windows Admin Tool Kit Click here and download it now
April 14th, 2011 5:11am
Where should I try this? Are you saying I should change the stored procedure to the above? In BIDS, I am not running a query, only running the Stored Procedure. So I can only change the sored procedure, but if I enter the above in the SP somewhere, surely
I will get an error about trying to declare @AssetGroup twice?
April 14th, 2011 8:06am
Hi
create proc [dbo].[BFWD_Depn]
@CompanyID nvarchar (4), @AssetGroup
nvarchar (max),@Date datetime
AS
begin
set nocount
on
set dateformat dmy
declare @month int, @year
int, @day int
--- set @Date = '15/12/2011'
set @month = MONTH(@Date)
set @year = YEAR(@Date)
set @day = DAY(@Date)
SET @AssetGroup =
Char(44) + @AssetGroup + Char(44)
if ((@year<=2010) or (@year=2011
and @month<=10))
begin
Add this condition in your query
@AssetGroup Like '%,' + AssetGroup +
',%'
Rajesh Jonnalagadda http://www.ggktech.com
Free Windows Admin Tool Kit Click here and download it now
April 14th, 2011 8:13am
Thank you VERY MUCH!!! You are my hero!!
April 14th, 2011 8:36am