Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
subt13
Starting Member
11 Posts |
Posted - 2010-01-05 : 19:41:50
|
| Hello, I have a dynamic query that I'm executing with sp_executesql and I want to take its output and insert it into a #temptable that will be defined by the output of the sp. pseudo code:insert exec sp_executesql @theDynamicSql into #temptable.The reason the #temp table must be defined by the sp output is that the number of columns and the names of columns will change.Thanks. |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-01-06 : 01:45:36
|
| use select into |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
subt13
Starting Member
11 Posts |
Posted - 2010-01-06 : 11:19:28
|
| openrowset takes a string as the query to run, so can it handle sp_executesql @param in the string? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-06 : 11:24:51
|
| http://support.microsoft.com/kb/314520 |
 |
|
|
subt13
Starting Member
11 Posts |
Posted - 2010-01-06 : 11:42:44
|
| Also, as an alternative, is it possible to do something like: select * from ( exec sp_executesql @theDynamicSql ) ? |
 |
|
|
subt13
Starting Member
11 Posts |
Posted - 2010-01-06 : 11:46:37
|
| [code]http://support.microsoft.com/kb/314520[/code] If you read my first post, you will understand that this will run into the same problem with exec. Reread my first post.Thanks. |
 |
|
|
subt13
Starting Member
11 Posts |
Posted - 2010-01-06 : 12:29:36
|
| I have found a solution that will work. I will just create the temp table in the dynamic query using ## instead. |
 |
|
|
|
|
|