• Based on your original post, the correct code is this:

    create table #temp(

    ID int,

    Name varchar(20)

    )

    insert into #temp

    values (10, 'Helen'),

    (20, 'Joe'),

    (30, 'Blake');

    with cte as (

    select * from #temp

    )

    select * from cte

    union all

    select * from cte;

    The cte's must defined prior to the selects and both cte's are identical therefore only one is needed.

    Now, how about providing the actual problem you are trying to solve.