insert @v_table select * from 表

解决方案 »

  1.   

    declare @t table(col1 int,col2 int)
    insert into @t select 1,2
    insert into @t select 2,3
      

  2.   

    declare @t table(
    id varchar(80)
    )insert @t select p_msg_id from inbox
      

  3.   

    --SQL中有表变量
    --定义表变量
    declare @t table(id int,columns varchar(10))
    --操作就和普通表操作一样.它驻留在内存中。
      

  4.   

    我想用一个table类型的变量储存一个select查询的结果,怎么做?
    注意,是用变量,不是用select into newtable===>表变量,必须手工创建,不能由select * into @tb from tb 语句得到,
    正确写法是:
    declare @tb table (col varchar(10),....)
    insert into @tb
    select * from tb
      

  5.   

    create table #t(id int, name varchar(100))insert into #t(id, name)
    select 1,'aaa' union all
    select 2,'bbb' union all
    select 3,'ccc' union all
    select 4,'ddd'select * from #tdeclare @tp table (id int, name varchar(100))insert into @tp
    select *
    from #tselect * from @tpdrop table #t