To generate a temporary table dynamically without specificng the structure up front, use the
The datatypes will be determined by the base datatypes in the source tables (or expressions if an explicit convert is done)
answered Sep 03 '12 at 07:29 AM
Kev Riley ♦♦
When you say "dynamic query results", I assume you mean the results from a string containing sql, that you execute with EXECUTE('select * from someTable') If that's the case, you have only one option that I can think of: Use a global temporary table.
Then you can use the global temporary table in your code. Like this:
The problem with this solution is that the temporary table you create is global. It will cause problems in a multi-user environment, if this is run by two users at the (more or less) same time the SELECT INTO will fail since the table already exists.
answered Sep 03 '12 at 11:12 AM