create table #临时表(结构和返回结构相同 int)insert #临时表 exec 过程名select * from #临时表

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/2142/2142802.xml?temp=.5115167
      

  2.   

    http://expert.csdn.net/Expert/TopicView1.asp?id=2142802
      

  3.   

    参考:create table #table(id int identity,txt varchar(1000))
    insert into #table(txt) exec master..xp_cmdshell 'dir c:\*.'
    select * from #table用存储过程插入数据
    在INSERT 语句中可以通过执行存储过程来取得要插入的数据所插入的数据是存储
    过程中SELECT 语句所检索的结果集使用存储过程插入数据的语法如下
    INSERT [INTO]
    { table_name WITH ( <table_hint_limited> [...n])
    | view_name
    | rowset_function_limited }
    { [(column_list)]
    EXECUTE procedure
    其中procedure 既可以是一个已经存在的系统存储过程或用户自定义的存储过程也
    可以在INSERT 语句中直接编写存储过程
    例11-4 对每个部门求员工工资总额并把结果存入department_info 表中
    use pangu
    insert into department_info(dept_id, d_wage)
    execute ('select dept_id, sum(e_wage)
    from employee
    group by dept_id')
    select * from department_info
    运行结果如下
    (7 row(s) affected)
    dept_id d_chief_name d_location e_num d_wage
    ------- -------------------- -------------------------------------------------- ------ ------------
    1001 dbo NULL NULL 15000.0000
    1002 dbo NULL NULL 19500.0000
      

  4.   

    create table #temp(结构和返回结构相同 int)
    insert #temp exec yourprocname
    select * from #temp
      

  5.   

    create table # (col1.........)insert into # exec proc_nameselect * from #drop table #
      

  6.   

    返回數據集列是動態的能不能不create #來操作??就像
    select *
    into #aaa
    from tablea一樣我試了不行不知大家有甚麼好辦法
      

  7.   

    你可以考虑使用table变量,声明变量的方法是声明普通变量和建立表的结合。详悉方法请查看帮助文件。
      

  8.   

    用全局临时表:create proc 过程名
    as
    select * into ##全局临时表 from 表
    go----
    exec 过程名
    select * from ##全局临时表