title: T-SQL: Insert in table results of CTE
body: <p>I have this TSQL syntax :</p>
  
  <pre><code>WITH cte AS(
  SELECT Stamps, row_number() over (order by (SELECT 1)) rn from week
  unpivot      
  (Stamps FOR Day IN ([Sun], [Mon], [Tue], [Wed], [Thu], [Fri], [Sat]) ) AS unpvt )
  
  SELECT Stamps + ': ' +STUFF((SELECT ','+cast(rn as varchar(9)) from cte where Stamps=A.TimeStamps FOR XML PATH('')), 1 , 1 , '' ) from cte A group by Stamps
  </code></pre>
  
  <p>This give me for each "Stamps" the number of the day.
  For example if the Table is :</p>
  
  <p><code>S2 | S0 | S0 | S1 | S1 | S3 | S2</code></p>
  
  <p>The result will be:</p>
  
  <pre><code>S0 : 2,3
  S1 : 4,5
  S2 : 1,7
  S3 : 6
  </code></pre>
  
  <p>This part works well, but now I would like to put this result in a table</p>
  
  <p>Like <code>Insert Into mytable (S0, S1, S2, S3) = ('2,3','4,5','1,7','6')</code></p>
  
  <p>But when I do Set after or before it doesn't work.
  How can I do it?
  Thanks</p>