Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Error: The statement terminated. The maximum recursion 100 has been exhausted before statement completion

$
0
0

Team,

I am getting the below error when I fired query in the database.

Error

The statement terminated. The maximum recursion 100 has been exhausted before statement completion.

Query

DECLARE @RiskID varchar(10)

SET @RiskID = '329314'

;With CTE
AS
(

SELECT RISK,RELATEDRSK,CAST('#-'+CONVERT(varchar,RISK)+'--'+CONVERT(varchar,RELATEDRSK)+'-' as varchar(2000)) as txt
FROM [dbo].RELATED_RISK
WHERE RISK = @RiskID

UNION ALL
SELECT c.RISK, t.RELATEDRSK,CAST( convert(varchar,c.txt)+'-'+CONVERT(varchar,t.RELATEDRSK)+'-'as varchar(2000))
FROM CTE c
INNER JOIN [dbo].RELATED_RISK t
ON t.RISK = c.RELATEDRSK
WHERE txt not like '%-'+convert(varchar,t.RELATEDRSK)+'-%'
)

SELECT distinct RELATEDRSK
 FROM CTE where RELATEDRSK <> @RiskID

Thanks!

Kiran


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>