I have a sql query that takes about 15 seconds to run in ssms, but when I run it in ssrs, it takes 5-7 minutes. From everything I've read this appears to be from "parameter sniffing" so I've declared variables inside the query to bypass this, however I've still running into issues with multiple parameters.
With:
My passed in param is: @Places
create table #places (place varchar(50))
insert into #places select Val from dbo.parseValues(@Places,',')
select * from mytable m
inner join #places p on p.place = m.place
drop table #places
and this works if I only select one place when running the report, but otherwise it throws an error that says:
For more information about this error navigate to the report server on the local server machine, or enable remote errors ---------------------------- Query execution failed for dataset 'dataset1'. (rsErrorExecutingCommand) ---------------------------- An error has occurred during report processing. (rsProcessingAborted)
The ParseValues function comes from http://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
Does anybody have any other ideas?
'Val1, Val2, Val3'
. It actually treats it like an object which sends value as'Val1', 'Val2', 'Val3'
. Thus the parsing fails. – SouravA