Reputation: 5
I would like to play with the results of my dynamic query executable with
execute sp_executesql @query; [it has many columns dependable on variables]
how can i export this into #temptable
?
Upvotes: 0
Views: 374
Reputation: 39767
You can't, unless you know in advance number/type of the columns. If you do (e.g. based on variables) you can create the temp table first and then do
INSERT INTO #TempTable
EXECUTE ...
Another possibility (not recommended) do a SELECT INTO ##GlobalTempTable..
inside of your dynamic SQL, this way the table will be accessible to outside scope.
Upvotes: 1