Using table Variable

  • I have an requirement of inserting the output of "DBCC inputbuffer "

    into a table variable..

    I tried with the following query,

    DECLARE @T3 TABLE

    (

    A SYSNAME,

    B SYSNAME,

    [INPUT_BUFFER] NVARCHAR(1200),[SPID] INT NULL

    );

    INSERT @T3(A,B,[INPUT_BUFFER])

    EXEC SP_EXECUTESQL ('DBCC INPUTBUFFER(55)WITH NO_INFOMSGS')

    But the sql server prompts me that

    "Server: Msg 197, Level 15, State 1, Line 12

    EXECUTE cannot be used as a source when inserting into a table variable."

    I can accomplish the same using #tables (temporary tables ).

    Can any one suggest a way to accomplish the same using tables variables..

    Regards,

    Paarthasarathy K, Chennai

    (Life is Full of Compilation Errors and Unhandled Exceptions )

    Kindest Regards,
    Paarthasarathy
    Microsoft Certified Technology Specialist
    http://paarthasarathyk.blogspot.com

  • Why so hell-bent on using table variables?  They live in the exact same place that Temp Tables do and have the disadvantage of not using statistics.  Use the Temp Table

    If you're trying to do this in a function, that's a whole 'nother story... personnally, I wouldn't try to do this in a function... perhaps a sproc but not a UDF.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

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

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