stored procedure to insert into a table variable?

  • Is it possible to use a stored procedure to insert into a table variable in layman's terms here is what I'm trying to do...

    Here is the first Proc

    ******************************************

    Create Procedure dbo.sp_Test

    as

    select 'Now','Then','Later'

    ******************************************

    Later call the first Proc in the second and populate a table

    ******************************************

    Create Procedure dbo.sp_Test2

    as

    declare @T table(when1 varchar(50),when2 varchar(50),when3 varchar(50));

    Insert Into @T

    Values(exec sp_Test)

    Select *

    from @T

  • You cannot insert the data from an execute into a table variable, you could use a temp table instead.



    Shamless self promotion - read my blog http://sirsql.net

  • Table variables are fast but they can only be used in the context in which they were Declared. They can't be used with:

    Select .. Into @TblVar

    Insert @TblVar Execute ...

    Passed to/from a batch via Exec or sp_ExecuteSQL

    Kind of limits their use...



    PeteK
    I have CDO. It's like OCD but all the letters are in alphabetical order... as they should be.

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

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