当所有列都具有相同名称时选择INTO

时间:2019-06-29 19:38:03

标签: sql sql-server-2008 sql-server-2005

如何通过此查询选择结果到新表中。 选择“ INTO”不起作用,因为所有列都具有相同的名称:N 谢谢。

WITH Balls(N)
 AS (SELECT number
     FROM  master..spt_values
     WHERE type='P'
     AND number BETWEEN 1 AND 41)
SELECT *
FROM   Balls B1
       JOIN Balls B2
         ON B2.N > B1.N
       JOIN Balls B3
         ON B3.N > B2.N
       JOIN Balls B4
         ON B4.N > B3.N
       JOIN Balls B5
         ON B5.N > B4.N
       JOIN Balls B6
         ON B6.N > B5.N 

1 个答案:

答案 0 :(得分:0)

分配不同的名称:

SELECT b1.number as number1,
       b2.number as number2,
       b3.number as number3,
       b4.number as number4,
       b5.number as number5,
       b6.number as number6
INTO my_table
FROM . . .