I have this query:
Select
'<ALL>' as name,
'<ALL>' as pid,
'<ALL>' as type
union all
Select distinct
instructor.name as name,
instructor.Pid as pid,
instructor_type as type
From sisinfo.dbo.SISCRSI instructor
inner join section_info as section
on section.sctn_id_code = instructor.sctn_id_code
Where section.sctn_term_code in (@Terms)
and section.subj_code in (@Subject)
order by name
When I run it in SSMS, it completes in pretty close to zero time. It also runs fast in the SSRS query designer when I feed it some values. But when I preview the report, the query takes at least two minutes to run. I'm not sure what is going on here, I've never had this kind of a problem with SSRS before.
See Question&Answers more detail:os