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]