CodePudding user response:
The number of columns indefinite words need to use the select * it INTO a temporary table, try the global temporary tableDECLARE @ SQL NVARCHAR (200)='select the as 1 a, 2 b as'
EXEC (' select * into # # temp from t '(' + SQL + @'))
SELECT * from # # temp
DROP TABLE # # temp

CodePudding user response:
Good thinking the moderators of February,It is important to note, however, if it is in the program calls, concurrent invocations will have problems,
Because global temporary tables are common, if concurrent calls with name conflicts will appear,
So the global temporary table name best is random,
CodePudding user response:
Directly SELECT INTO rode the exec (@ SQL) and then from rode the temporary table inserted INTO the official table, finally delete rode a temporary table,CodePudding user response:
I also encountered this problem, various methods are tried, can't, how will the EXEC SQL) (@ the result set (dynamic) column is inserted into the list, and then to deal with these data?