Problems with INSERT from stored procedure

  • Simply put:

    INSERT EXEC Statement cannot be nested

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Find the solution. Can do the same using functions:

    CREATE FUNCTION test_0 ()

    RETURNS @t table (ID int)

    as

    begin

    insert into @t values (1),(2),(3)

    RETURN

    end

    go

    CREATE FUNCTION test_1 ()

    RETURNS @t1 table (ID int)

    as

    begin

    insert into @t1 (ID)

    (select ID from test_0())

    RETURN

    end

    go

    declare @t2 table (ID int)

    insert into @t2 (ID)

    (select ID from test_0())

    insert into @t2 (ID)

    (select ID from test_1())

    select ID from @t2

    drop function test_1,test_0

    go

Viewing 2 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply