June 2, 2010 at 3:23 am
Hi,
I have an unusal query which I am looking more for general advice than specific code.
I have a stored procedure which creates a dynamic pivot statement as the number of columns for the output is unknown.
The results of the pivoted query needs to be returned into a table for further analysis.
Usually I would have created a destination table, then inserted the rows using something like:
INSERT INTO #temp_resuts
EXEC (@sqlStmt)
The problem is that I don't know how many columns there will be to create the temp table first so I though SELECT INTO would make more sense as it creates the table during the insert, the problem is I am not sure if this is possible.
Is there anyway of doing something like
SELECT * INTO #temp_resuts FROM (EXEC (@sqlStmt))
If anyone can help it would be most appreciated.
MCITP SQL 2005, MCSA SQL 2012
June 2, 2010 at 3:51 am
This was removed by the editor as SPAM
June 2, 2010 at 3:55 am
Thanks for the help XML is not my forte but it least gives me a head start. Thank You.
MCITP SQL 2005, MCSA SQL 2012
June 2, 2010 at 6:26 am
Hi,
Option two works well. Thanks.
MCITP SQL 2005, MCSA SQL 2012
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply