插入一条数据的语句是: insert into table1(field1,field2) values(value1,value2),
那我要是同时插入5条数据该如何写呢?不要一条一条的插入, 要同时插入。
再一次插入5条数据的时候覆盖以前的5条数据。
O(∩_∩)O谢谢

解决方案 »

  1.   

    insert into table1(field1,field2)
    select value1,value2 union all
    select value3,value4 union all
    .....
      

  2.   

    insert into table1(field1,field2)
    Union All select value1,value2 union all
    Union Al select value3,value4 union all
    .....
      

  3.   


    insert into table1(field1,field2)
    select value1,value2 union all
    Union Al select value3,value4 union all
    .....
      

  4.   

    --我错了,没看到Union All
    --试试增加事务
      

  5.   

    可以的。。
    打个比方: 
    create database test
    create table test(a int,b int)
    insert into test
    select 1,2 union all
    select 3,4
      

  6.   

    create  table parent(BOMID int,parentName varchar(8))
    insert into parent
    select 10001,'电脑' union all
    select 10002,'主机' union all
    select 10003,'华硕主板'--覆盖=删除后再插入
    delete from parent--重新insert
    insert into parent
    select 10001,'电脑' union all
    select 10002,'主机' union all
    select 10003,'华硕主板'
      

  7.   


    declare @table table (id sql_variant,col sql_variant)
    insert into @table
    select 1,'a' union all
    select 2,'a' union all
    select 3,'a' union all
    select 4,'a' union all
    select 5,'a' select * from @table
      

  8.   

    declare @table table (id sql_variant,col sql_variant)
    insert into @table
    select 1,'a' union all
    select 2,'a' union all
    select 3,'a' union all
    select 4,'a' union all
    select 5,'a' select * from @table