CTE error: "Types don't match between the anchor and the recursive part"

Posted by priyanka.sarkar on Stack Overflow See other posts from Stack Overflow or by priyanka.sarkar
Published on 2009-12-03T07:35:31Z Indexed on 2010/04/12 13:33 UTC
Read the original article Hit count: 974

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sql