I know that on this exception there are several questions about this exception, but nothing is visible that helps me.
I have the following query giving me a "Multi-part identifier 'claim.fiData' could not be bound"-Exception:
SELECT claim.idData FROM tabData as claim
INNER JOIN dbo._previousClaimsByFiData(claim.fiData) AS prevClaim
ON prevClaim.idData=claim.fiData
GROUP BY claim.idData
HAVING(prevClaim.fiMaxActionCode IN (8, 23, 24) and
prevClaim.Repair_Completion_Date >= DATEADD(day,-90,prevClaim.Repair_Completion_Date))
ORDER BY claim.idData
previousClaimsByFiDatais a table-value-function that returns all previous records. You can find it here if you are interested. Now I want to find all the claims that had previous claims in the last 90 days with maxActionCode IN (8, 23, 24).
What I also tried is the following:
SELECT count(*) FROM tabData as claim
where exists(
select 1 from dbo._previousClaimsByFiData(claim.fiData)as prevClaim where
prevClaim.fiMaxActionCode IN(8, 23, 24)and
prevClaim.Repair_Completion_Date >= DATEADD(day,-90,claim.Repair_Completion_Date)
)
But that gives me an "The maximum recursion 100 has been exhausted before statement completion"-Exception.
Why do I get these exceptions and how to avoid them?
thank
EDIT:
asked another question that comes down to the main problem. I can remove this when I get a response.
UPDATE:
.
, Cross Apply.
, . " 100 " .
, OPTION (MAXRECURSION 0), " ", Inline-TVF.
:
SELECT claim.idData FROM tabData claim
CROSS APPLY dbo._previousClaimsByFiData(claim.fiData)AS tvfData
GROUP BY claim.idData,claim.Repair_Completion_Date,tvfData.Repair_Completion_Date,tvfData.fiMaxActionCode
HAVING(tvfData.fiMaxActionCode IN (8, 23, 24) and
tvfData.Repair_Completion_Date >= DATEADD(day,-90,claim.Repair_Completion_Date))
ORDER BY claim.idData
UPDATE: , OPTION (MAXRECURSION 0) SELECT.