I have created a dynamic query which returns the number of columns from table as:
set @query = 'select '+@cols+' from [Sample] '
Now I want to fill a temporary table by executing this query, When I try this
select * into #table from execute(@query).
I get following error:
Incorrect syntax near the keyword 'execute'
And
Incorrect syntax near ')'
However running this command returns the result accurately : execute(@query)
Note: I have tried OPENROWSET which is not supported in sql-azure.
Please help if there is any other work around.