I have
;with cte as
(
select rn=1, name = CAST('name'as varchar(50))
union all
select rn+1, CAST(name as varchar(50))+ CAST( (rn+1) as varchar(50))
from cte where rn<100)
select * from cte
error
Msg 240, Level 16, State 1, Line 1
Types don’t match between the anchor and the recursive part in column “name” of recursive query “cte”.
Try something like
You have to remember that all fields in the anchor and the recursive part have to be of the same type. That also goes for varchar fields.