现有表Table1、Table2,结构如下,求一SQL语句,将Table1的所有数据存储到Table2中,谢谢~
Table1
col1   col2   col3   col4   col5
1      2      3      4      5
6      7      8      9      10
11     12     13     14     15
16     17     18     19     20
.....
1001   1002   1003   1004   1005
table2
newCol
1
2
3
4
5
6
....
1005

解决方案 »

  1.   

    insert into Table2(newCol) select col1 from Table1
    union all select col2 from Table1
    union all select col3 from Table1
    union all select col4 from Table1
    union all select col5 from Table1
      

  2.   

    insert table2
    select col1 from tabel1 union all
    select col2 from tabel1 union all
    select col3 from tabel1 union all
    select col4 from tabel1 union all
    select col5 from tabel1
      

  3.   

    现有表Table1、Table2,结构如下,求一SQL语句,将Table1的所有数据存储到Table2中,谢谢~
    Table1
    col1   col2   col3   col4   col5
    1      2      3      4      5
    6      7      8      9      10
    11     12     13     14     15
    16     17     18     19     20
    .....
    1001   1002   1003   1004   1005insert into tb2 select * from tb1
      

  4.   

    弄成一列?insert into tb2 (select col1 from tb2 union all select col2 from tb2 union all select col3 from tb2 union all select col4 from tb2 union all select col5 from tb2)
      

  5.   

    create table tb(col1 int , col2 int , col3 int , col4 int , col5 int)
    insert into tb values(1,2,3,4,5)
    insert into tb values(6,7,8,9,10)
    insert into tb values(11,12,13,14,15)
    insert into tb values(16,17,18,19,20)
    goselect * from
    (
      select col1 from tb union all
      select col2 from tb union all
      select col3 from tb union all
      select col4 from tb union all
      select col5 from tb 
    ) t order by col1drop table tb/*
    col1        
    ----------- 
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20(所影响的行数为 20 行)
    */
      

  6.   

    insert into tb1
    select * from 
    (
      select col1 from tb union all
      select col2 from tb union all
      select col3 from tb union all
      select col4 from tb union all
      select col5 from tb
    ) t order by col1
      

  7.   

    SELECT * INTO TABLE2 FROM TABLE1
      

  8.   

    insert into 55
    select col1 from tb union ..... order by col1