我本地的SQLinsert into TempTable(id,name)
values(4,'a'), 
      (5,'b'),
      (6,'b'),
      (7,'b'),
      (8,'b')没问题,能插入成功服务器上的SQLinsert into TempTable(id,name)
values(4,'a'), 
      (5,'b'),
      (6,'b'),
      (7,'b'),
      (8,'b')语法错误,错误具体如下:
消息 170,级别 15,状态 1,第 2 行
第 2 行: ',' 附近有语法错误。不知为什么,所有的sql语句都是在英文输入法下写的。

解决方案 »

  1.   

    insert into TempTable(id,name)
    select 4,'a' union all 
    select 5,'b' union all 
    select 6,'b' union all
    select 7,'b' union all
    select 8,'b'
      

  2.   

    insert into TempTable(id,name)
    select 4,'a'
    union  
    select 5,'b'
    union  
    select 6,'b'
    union  
    select 7,'b'
    union  
    select 8,'b'
      

  3.   

    insert 一行insert into temptable(id,name) values(1,'a')
    insert into temptable(id,name) select 1,'a'insert 多行
    insert into temptable(id,name) 
    select 1,'a' union all
    select 2,'b' union all
    select 3 ,'c'
      

  4.   

    有这样的语法?
    学习insert into TempTable(id,name)
    SELECT 4,'a' UNION ALL
     SELECT     5,'b')UNION ALL
    SELECT      6,'b'UNION ALL
    SELECT      7,'b'UNION ALL
    SELECT      8,'b'
      

  5.   

    2008才有这个功能,
    用UNION 连在一起插入
      

  6.   

    SQL2008可以这样写,之前的版本只能union all
      

  7.   

    create table temptable
    (
    id int,
    name varchar(20)
    )insert into TempTable(id,name)
    values(4,'a'), 
          (5,'b'),
          (6,'b'),
          (7,'b'),
          (8,'b')
          drop table temptable
    经测试 2008 是可以的 
    05 是不行的 只能用union all
      

  8.   

    insert into TempTable(id,name) 
    select 4,'a' union all 
    select 5,'b' union all 
    select 6,'b' union all 
    select 7,'b' union all 
    select 8,'b' 
      

  9.   

    注意,如果数据过多,使用union可能还不如使用多个insert速度快
      

  10.   

    p这个语法只有在sql2008上才可以,是08新增的功能,其他的版本都不行的。