I can't figure out what can be causing this.When I use this querySelect top 1000 a.EmployeeID,b.*from #TmpActiveEmployeesWSeverance across apply dbo.fn_Severance_AccountItemsTable(a.EmployeeID,a.BenefitTypeID,null,null,null,null) border by a.EmployeeID,a.BenefitTypeID
It runs 4 secondsIf I try to insert the results into anything It runs > 5 minutes (I have yet to let it finish)I have tried the two following pieces of code, both with the same resultsSelect top 1000 a.EmployeeID,b.*into #Tmpfrom #TmpActiveEmployeesWSeverance across apply dbo.fn_Severance_AccountItemsTable(a.EmployeeID,a.BenefitTypeID,null,null,null,null) border by a.EmployeeID,a.BenefitTypeID--andInsert Into TRP_ActiveEmployeesWSeverance(EmployeeID,PK,BeginningBalance,BenefitInterestRowID,BenefitInterestID,BenefitTypeID,DateReceived,InvoiceDate,Amount,Hours,Fraction1,Fraction2,Interest,InterestAmount,StartDate,EndDate,PeriodApplied,Offset,Reserve,Account,BenefitClosedID,PaidOut,ClosedAccount,ai,ClosedDate,StartAgain,PartialDividend,PartialFraction,SameDateCount)Select top 1000 a.EmployeeID,b.*from #TmpActiveEmployeesWSeverance across apply dbo.fn_Severance_AccountItemsTable(a.EmployeeID,a.BenefitTypeID,null,null,null,null) border by a.EmployeeID,a.BenefitTypeID
Any thoughts as to what can be disrupting this?