I have a dynamic @strQuery query @strQuery , when executed, produces a result with lots of columns. I want to insert the result from this dynamic query into a temporary table. I do this because I want to do some filtering in a temporary table and get the desired result.
A similar question was asked in the previous thread HERE in which a temporary table is first created, and then the data is inserted using INSERT INTO .
I want to avoid this step due to the long list of columns, as well as data types that are unknown to me.
select * into #tmh from exec(@strQuery)
Error message
Incorrect syntax next to the keyword "exec".
How to do it? Can this be done in this way? If not, specify another alternative to get the result when executing a dynamic query in the table. Thanks.
Mududir hasan
source share