I run the following query in SSRS. If I add declarations for two parameters, it works fine in the SQL Management Console.
declare @EMRQuery varchar(max) declare @CPSQuery varchar(max) set @EMRQuery = 'select Person.ExternalId from ml.Person join ml.Obs on Person.pId = Obs.pId join ml.ObsHead on Obs.hdId = ObsHead.hdId where ObsHead.name = ''SCHOOLREGDTE'' and Obs.xId = 1.e+035 and Obs.change = 2 and Obs.obsDate >= to_date(''' + convert(varchar(30), @DateYearStart, 120) + ''', ''YYYY-MM-DD HH24:MI:SS'') and Obs.obsDate < to_date(''' + convert(varchar(30), @DateQuarterEnd, 120) + ''', ''YYYY-MM-DD HH24:MI:SS'')' set @CPSQuery = 'select ic.ListName, count(distinct pp.patientprofileid) as PatCount from PatientProfile pp left join PatientInsurance pi on pp.PatientProfileId = pi.PatientProfileId and pi.OrderForClaims = 1 and pi.Inactive <> 1 left join InsuranceCarriers ic on pi.InsuranceCarriersId = ic.InsuranceCarriersId join OpenQuery(EMR_LIVE , ''' + replace(@EMRQuery, '''', '''''') + ''' ) Students on pp.PatientId = Students.ExternalId group by ic.ListName ' exec(@CPSQuery)
However, when I connect it to SSRS, it does not register that any fields are available for the report. How can I convince SSRS that I have fields for work? Thanks.
Edit: I just declared the parameters in the request and recognized the field names.
declare @DateYearStart datetime declare @DateQuarterEnd datetime set @DateYearStart = '2011-07-01' set @DateQuarterEnd = '2012-03-31'
Of course, this is a mistake because I declared the parameters twice, once as request parameters and once in the request. But, as soon as I commented on the above lines, I again lost the fields.
SarekOfVulcan
source share