December 21, 2011 at 3:05 am
Hi All,
Please give me an idea to export the pivot results to a temporary table in Sql Server.
Requirements:
1) Donno how many columns after pivot done in sql server
Do we have any solution in sql server to save or export this pivoted results to a sql table.
Waiting for your good responses,
Thanks & Regards,
Sri Sagar. P
December 21, 2011 at 4:15 am
If the number of columns is unknown, I would use the DynamicCrossTab approach instead of PIVOT.
Please see the two related articles referenced in my signature.
Since you most probably need to use Dynamic SQL, you cannot use a normal temp table (since it would be out of scope). There are two options I can think of:
1) create a global temp table in the sproc that calls the dynamic SQL and insert into that global temp table (use INSERT INTO ##GlobalTempTable SELECT... inside the dynamic SQL part) or
2) create a permanent table and insert into that table (you should consider concurrent inserts, so a unique sprocID column could be used to identify what values belong to a specific sproc.
December 21, 2011 at 6:21 am
Really Thanks for the good solution.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply