比如有表 tblname(col1,col2,col3)
下载有3条数据:
  1,'aa',8
  2,'bb,9
  3,'rrr',6在ms sql下 怎么写一个语句插入。

解决方案 »

  1.   

    insert into tablename
    select 1,'aa',8
    union all
    select 2,'bb',9
    union all
    select 3,'rrr',6
      

  2.   

    insert into tblname select 1,'aa',8 union all select  2,'bb,9 union all select  3,'rrr',6
      

  3.   


    select 1,'aa',8
    union 
    select 2,'bb',9
    union 
    .....
      

  4.   

    if object_id('tb') is not null
    drop table tbcreate table tb
    (
    type  int,
    uname  char(10),
    poiny  int,
    other1  char(20),
    other2  char(20)
    ) insert into tb
    select
    1,    'a',        2,      'a',        'b' 
    union all
    select
    1,    'd',        7,      'a',        'b'
    union all
    select
    2,    'a',        3,      'a',        'b' 
    union all
    select
    1,    'c',        5,      'a',        'b' 
    union all
    select
    3,    'a',        1,      'a',        'b' 
    union all
    select
    1,    'b',        2,      'a',        'b' 
    union all
    select
    1,    'e',        12,    'a',        'b'
    union all
    select
    2,    'b',        3,      'a',        'b' 
    union all
    select
    3,    'b',        6,      'a',        'b'