September 24, 2011 at 11:34 pm
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
September 25, 2011 at 1:51 am
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...
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy