CTE error: "Types don't match between the anchor and the recursive part"
- by priyanka.sarkar
I am executing
;with cte as
(
select 1 as rn, 'name1' as nm
union all
select rn+1,nm = 'name' + CAST((rn+1) as varchar(255))
from cte a where rn<10)
select * from cte
and is receiving the error
Msg 240, Level 16, State 1, Line 2
Types don't match between the anchor and the recursive part in column "nm" of recursive query "cte".
Where I am making the mistake?
Thanks in advance