create table #student(s# int,sname varchar(10),age int)create table #study (s# int, c# char(1),score int)insert into #student 
1,'xiaozhu',10 union all select 2,'xiaomao' ,9union all select 3,'xiaozhe' ,7union all select 4,'xiaophai',8 union all select 5,'xiaoduo',9insert #study select 1,'A',99 union all select 1,'B',90 union all select 1,'C',99 union all select 2,'A',99 union all select 2,'b',99 union all select 2,'c',98 union all select 3,'A',99 union all select 3,'b',92 union all select 3,'c',91 union all select 3,'d',90 union all select 4,'A',88 union all select 4,'B',96 insert into #student 
1,'xiaozhu',10 union all select 这个union all select 
什么意思
然后我用这个sql 执行不了啊 呵呵

解决方案 »

  1.   

    insert into #student 
    1,'xiaozhu',10 union all select 2,'xiaomao' ,9union all select 3,'xiaozhe' ,7union all select 4,'xiaophai',8 union all select 5,'xiaoduo',9
    要把这些都执行...
      

  2.   

    有错,#student后面少了个select 
      

  3.   

    union all :联合,连接
      

  4.   

    insert into #student  select
    1,'xiaozhu',10 union all select 2,'xiaomao' ,9union all select 
    ........
      

  5.   

    insert into #student select
    1,'xiaozhu',10 union all select 2,'xiaomao' ,9union all select 3,'xiaozhe' ,7union all select 4,'xiaophai',8 union all select 5,'xiaoduo',9
      

  6.   


    是这样 加个select就好了但是我的问题是 这个union all select 
    在这里是什么意思了?
      

  7.   

    union all 是相同结构的表联合啊
      

  8.   


    select 1,'xiaozhu',10 
    union all 
    select 2,'xiaomao' ,9
    你看看这个是什么结果,应该就明白了
      

  9.   

    我的理解是这样,看大家觉得对不对?select 
    1,'xiaozhu',10 union all select 2,'xiaomao' ,9 union all select 3,'xiaozhe' ,7 union all select 4,'xiaophai',8 union all select 5,'xiaoduo',9 是链接了 多个select 
    的结果形成一个集合
    插入到表里 是吗》?
      

  10.   

    1.只有union all 或union 没有union all select 
    2.union all 一般是将两个select 结果集合并,即使有重复的记录也不会去重
    如select 1 union all select 1 union all select 2,结果是3条记录
    3.union 与union all 类似,不同的是它会去掉重复的记录,如2中用union 结果就是两条记录示例:
    SELECT 1
    UNION ALL 
    SELECT 1
    UNION ALL 
    SELECT 2--result           
    /*
    ----------- 
    1
    1
    2(所影响的行数为 3 行)*/SELECT 1
    UNION  
    SELECT 1
    UNION  
    SELECT 2--result
    /*            
    ----------- 
    1
    2(所影响的行数为 2 行)*/
      

  11.   

    就是insert into ...select 语句 相当于插入批量数据