SQL Server - Selectively inserting fields into temp table

  • I am executing a SP within a SP. The SP returns say 10 params. I am interested in only 5 of them. How do I insert only these 5 into the temp table.

    The code I have so far:

    DECLARE @tmpUnion TABLE

    (

    UnionCode VARCHAR(10),

    UnionDate DATETIME,

    UnionPosition VARCHAR(30),

    UnionInitFees BIT,

    UnionDues BIT

    )

    --getDetails returns 10 params. I need only these 5

    INSERT INTO @tmpUnion

    (UnionCode, UnionDate, UnionPosition, UnionInitFees, UnionDues)

    EXEC getDetails

    @iUserId = @OriginalLoginId

  • if the stored procedure returns 10 columns, you'll have to have a temp table that catches all ten columns...after that, you could ignore the other columns and continue from there.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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