I have a report that I inherited, that has stopped working correctly. Other SSRS reports work fine. We are on IE version 11.This report has a subreport. The queries behind both the main report and subreport return data in a few seconds. When I run the main report without the subreport, it returns data in a few seconds. When I run the subreport independently, it returns data in a few seconds. The main report has two parameters, @Group and @MRNParameter. @Group has no default value. @MRNParameter has a default value of -1. The subreport has has the same two parameters but, neither has a default value. Here is the sql for both reports.The intent of the report is this. List all invoices, Main Report, with the credit detail for each, subreport.Any thoughts?Main Report[code="sql"]set nocount oncreate table #FSC589(INV_NUM char(8),MRN varchar(10),POST_DT datetime)--Get invoices from IDX_INCOME and IDX_INCOMEMTD that have FSC-'CREDIT APPROVED'. There will be multiple FSCs per invoice.insert into #FSC589(INV_NUM, MRN, POST_DT)select a.INV_NUM, a.MRN, convert(datetime, a.POST_DT, 121)from IDX_INCOME ainner join (select distinct INV_NUM from IDX_INCOME where INV_FSC__1='CREDIT APPROVED' and GRP__2=@Group) b on a.INV_NUM=b.INV_NUMwhere a.GRP__2=@Groupgroup by a.INV_NUM, a.MRN, a.POST_DTinsert into #FSC589(INV_NUM, MRN, POST_DT)select a.INV_NUM, a.MRN, convert(datetime, a.POST_DT, 121)from IDX_INCOMEMTD ainner join (select distinct INV_NUM from IDX_INCOME where INV_FSC__1='CREDIT APPROVED' and GRP__2=@Group) b on a.INV_NUM=b.INV_NUMwhere a.GRP__2=@Groupgroup by a.INV_NUM, a.MRN, a.POST_DT--Get the most recent transaction for the invoice and enter into a temp tableselect INV_NUM, MRN, max(convert(datetime, POST_DT, 121)) as 'POST_DT'into #589Finalfrom #FSC589group by INV_NUM, MRNorder by INV_NUM--Create a temp table to hold invoice data with the INV_BALcreate table #Income(INV_NUM char(8),MRN varchar(10),FSC varchar (100),INV_BAL money,POST_DT datetime)--Get the most recent INV_BAL from IDX_INCOME by joining the invoice number and most recent date from #589Finalinsert into #Income(INV_NUM, MRN, FSC, INV_BAL, POST_DT)select b.INV_NUM, b.MRN, b.INV_FSC__1, b.INV_BAL, convert(datetime, b.POST_DT, 121) as 'POST_DT'from #589Final ainner join IDX_INCOME b on a.INV_NUM=b.INV_NUMand a.POST_DT=b.POST_DTgroup by b.INV_NUM, b.MRN, b.INV_FSC__1, b.INV_BAL, b.POST_DT--Get the most recent INV_BAL from IDX_INCOMEMTD by joining the invoice number and most recent date from #589Finalinsert into #Income(INV_NUM, MRN, FSC, INV_BAL, POST_DT)select b.INV_NUM, b.MRN, b.INV_FSC__1, b.INV_BAL, convert(datetime, b.POST_DT, 121) as 'POST_DT'from #589Final ainner join IDX_INCOMEMTD b on a.INV_NUM=b.INV_NUMand a.POST_DT=b.POST_DTgroup by b.INV_NUM, b.MRN, b.INV_FSC__1, b.INV_BAL, b.POST_DT--Get results for patient demographicsselect a.MRN, c.PatLastName, c.PatFirstName, c.ADDR1, c.City, c.State, c.ZIPfrom #Income ainner join (select INV_NUM, max(POST_DT) as 'POST_DT' from #Income group by INV_NUM) b on a.INV_NUM=b.INV_NUMand a.POST_DT=b.POST_DTinner join formatIDX_Patients c on a.MRN=c.MRNwhere INV_BAL<>0 and FSC='CREDIT APPROVED'group by a.MRN, c.PatLastName, c.PatFirstName, c.ADDR1, c.City, c.State, c.ZIPorder by c.PatLastName, c.PatFirstName[/code]Sub Report[code="sql"]set nocount oncreate table #FSC589(INV_NUM char(8),MRN varchar(10),POST_DT datetime)--Get invoices from IDX_INCOME and IDX_INCOMEMTD that have FSC-'CREDIT APPROVED'. There will be multiple FSCs per invoice.insert into #FSC589(INV_NUM, MRN, POST_DT)select a.INV_NUM, a.MRN, convert(datetime, a.POST_DT, 121)from IDX_INCOME ainner join (select distinct INV_NUM from IDX_INCOME where INV_FSC__1='CREDIT APPROVED' and GRP__2=@Group) b on a.INV_NUM=b.INV_NUMwhere a.GRP__2=@Groupgroup by a.INV_NUM, a.MRN, a.POST_DTinsert into #FSC589(INV_NUM, MRN, POST_DT)select a.INV_NUM, a.MRN, convert(datetime, a.POST_DT, 121)from IDX_INCOMEMTD ainner join (select distinct INV_NUM from IDX_INCOME where INV_FSC__1='CREDIT APPROVED' and GRP__2=@Group) b on a.INV_NUM=b.INV_NUMwhere a.GRP__2=@Groupgroup by a.INV_NUM, a.MRN, a.POST_DT--Get the most recent transaction for the invoice and enter into a temp tableselect INV_NUM, MRN, max(convert(datetime, POST_DT, 121)) as 'POST_DT'into #589Finalfrom #FSC589group by INV_NUM, MRNorder by INV_NUM--Create a temp table to hold invoice data with the INV_BALcreate table #Income(INV_NUM char(8),MRN varchar(10),FSC varchar (100),INV_BAL money,POST_DT datetime)--Get the most recent INV_BAL from IDX_INCOME by joining the invoice number and most recent date from #589Finalinsert into #Income(INV_NUM, MRN, FSC, INV_BAL, POST_DT)select b.INV_NUM, b.MRN, b.INV_FSC__1, b.INV_BAL, convert(datetime, b.POST_DT, 121) as 'POST_DT'from #589Final ainner join IDX_INCOME b on a.INV_NUM=b.INV_NUMand a.POST_DT=b.POST_DTgroup by b.INV_NUM, b.MRN, b.INV_FSC__1, b.INV_BAL, b.POST_DT--Get the most recent INV_BAL from IDX_INCOMEMTD by joining the invoice number and most recent date from #589Finalinsert into #Income(INV_NUM, MRN, FSC, INV_BAL, POST_DT)select b.INV_NUM, b.MRN, b.INV_FSC__1, b.INV_BAL, convert(datetime, b.POST_DT, 121) as 'POST_DT'from #589Final ainner join IDX_INCOMEMTD b on a.INV_NUM=b.INV_NUMand a.POST_DT=b.POST_DTgroup by b.INV_NUM, b.MRN, b.INV_FSC__1, b.INV_BAL, b.POST_DT--Get results for subreportselect a.INV_NUM, a.MRN, cast(a.INV_BAL as money) as 'InvoiceBalance'from #Income ainner join (select INV_NUM, max(POST_DT) as 'POST_DT' from #Income group by INV_NUM) b on a.INV_NUM=b.INV_NUMand a.POST_DT=b.POST_DTinner join formatIDX_Patients c on a.MRN=c.MRNwhere INV_BAL<>0 and FSC='CREDIT APPROVED' and a.MRN=@MRNParameter[/code]
↧