Create PROCEDURE a 
....
insert #temp
exec b
...Create PROCEDURE b
..
@sql = ...
insert #temp
exec @sql
..
执行 a 提示:INSERT EXEC 语句不能嵌套。
该如何解决呢?

解决方案 »

  1.   

    create proc p
    as
    select * from sysobjectsgoselect top 0 * into  test from sysobjectsinsert into test exec ('p')
    select * from test
    drop table test 
    drop proc p
      

  2.   

    那就是不能嵌套了反正你都是要Insert
    可以写成这样啊Create PROCEDURE b
    ..
    @sql ="insert #temp"
    @sql =@sql=....
     ...exec @sql
    ..
      

  3.   

    你的逻辑错误了,在b中已经insert了,a中还要insert干吗select top 0 * into  test from sysobjects
    gocreate proc a
    as
    exec ('b')gocreate proc b
    as
    insert into test
    exec ('select * from sysobjects')
    goexec adrop table test 
    drop proc a
    drop proc b
      

  4.   

    不是的,a里面也要insert 的,我要得到这个记录集进行汇总.
    我这个只是简写.
    a 是汇总
    b 是明细
    是针对不同的报表结果.