sql

if object_id('stu') is not null
drop table stu
create table stu([@num] int,[@name] char(10),[@sex] char(2))
insert into stu
select 1,'周辛驰','男'
select 2,'周杰伦','男'
select 3,'周瑜','女'这种插入法;为什么打开表只有一条记录;大家解释一下;我没有用过这种方法;

解决方案 »

  1.   

    if object_id('stu') is not null 
    drop table stu 
    create table stu([@num] int,[@name] char(10),[@sex] char(2)) 
    insert into stu 
    select 1,'周辛驰','男' UNION ALL
    select 2,'周杰伦','男' UNION ALL
    select 3,'周瑜','女' 
      

  2.   

    insert into stu 
    select 1,'周辛驰','男'  union all 
    select 2,'周杰伦','男'  union all 
    select 3,'周瑜','女' 
     
      

  3.   

    要用Union All哦,如果用Union的话会distinct掉相同的数据