I have two reports that I have developed in SSRS, both with embedded sql. Both reports are using the same parameter that allows selection of multiple values. One report is working perfectly; the other report appears to be failing to process the multi-valued parameter. I am very familiar with passing multi-valued parameters to a sql query, and both reports are using exactly the same code to process the @task report parameter:
declare @tasks nvarchar(4000)
set @tasks = @task
set @tasks = @tasks + ','
declare @tCount int
set @tCount = (len(@tasks) - len(replace(@tasks, ',', '')))
declare @next int
set @next = 1
declare @sep int
set @sep = charindex(',', @tasks, @next)
declare @filterVal nvarchar(50)
declare @tasklist table (filterID nvarchar(50))
while @tCount > 0
begin
if @next < len(@tasks)
begin
set @filterVal = substring(@tasks, @next, @sep-@next)
insert into @taskList
select @filterVal
set @next = @sep + 1
set @sep = charindex(',', @tasks, @next)
set @tCount = @tCount - 1
end
end
I have actually stripped out all of the code that returns the results to the report that is failing and deleted the tables that render the data. I am returning the code above that includes a "select filterID from @taskList" and passing the results to a table in the report. I'm still getting the same error message, so I am confident it is related to the multi-valued parameter.
My next step was to delete the report parameter and re-create it, hoping that possibly the multi-valued report parameter had somehow become corrupted. This made no difference.
I am completely baffled by this and have spent an entire day attempting to debug the problem. Any ideas?
Terry Francis