怎样把一表中的部分数据存放入一新表中?select * into newtable from oldtable where ....

解决方案 »

  1.   


    --建立测试环境
    Create Table oldtable
    (id Int Identity(1,1),
     bonus Int)
    --插入数据
    Insert oldtable Values(89)
    Insert oldtable Values(97)
    Insert oldtable Values(83)
    Insert oldtable Values(94)
    Insert oldtable Values(83)
    --测试
    select * into newtable from oldtable
    where id>3drop table oldtable,newtable
      

  2.   

    如果新表存在:
    insert 新表(字段1,字段2........)
    select 字段1,字段2......
    from 表
    where ........如果新表不存在:
    select 字段1,字段2.........
    into 新表
    from 表
    where ........