Skip to Content
0
Jan 06, 2023 at 07:44 PM

Insert into table variable from execute immediate or dynamic select

85 Views

I'm trying to replicate select * into #temp from TestTable, which creates a temp table with the same column structure and column names.

I'm aware that the below code is possible,

temp = select * from TestTable;

but the column list is going to be dynamic so trying something like below,

temp = (Execute immediate 'select '|| lv_columnslist ||' from TestTable;');

How can I achieve that?