How to loop columns of dynamic temporary table which is created inside storedprocedure in sql server 2005

  • Hi all,

    Please can anybody help me to loop columns of dynamic temporary table which is created inside stored procedure to capture the column name and to check some conditions to insert some data into that dynamic temporary table inside stored procedure only in sql server 2005.

    Thanks in advance

    Uday

  • You mmight try to get the list of column names via the sys,columns table:

    SELECT name

    FROM sys.columns WHERE object_id=object_id('#temp')

    ORDER BY column_id

    But if you want to insert data into a "unknown" table structure, you'll need to use dynamic SQL for it, too.

    What is the purpose of the sproc? Sounds like a "one fit all" approach which might not be the best solution. Hard to tell...



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

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

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