我要在一个表里面查询出来我要的好几条信息,放入另外一个表里面如果写sql存储过程呢?我写了错误的 只能插入最后的一条信息,那位高手,谢谢!

解决方案 »

  1.   

    create procedure p
    as
    begin
        insert into newtable(列1,列2...)
        select 列1,列2...from oldtable where 你的条件
    end
      

  2.   

    create procedure p_Add
    @name varchar(200)
    as 
    begin 
    insert into Tb(name) values(@name)
    select * from Tb
    select * from Tb where name=@name--查询
    end
      

  3.   


    INSERT INTO 目标表 SELECT * FROM 视图(来源N张表)
      

  4.   

    insert into table
    exec(select 字段,字段 from elsetable)
      

  5.   


    用个for 循环,一条一条的往进插入!