문제

I need to push the results from this code below into a undefined TEMP table. Temp table must be undefined because I wont know the column names of the result set .

declare @sql varchar(4000)
set @sql ='Select * from #Test'

exec (@sql) 

--Need to insert the final result set into #TempTableName because I need to use it in code lower down in my Stored Procedure.

도움이 되었습니까?

해결책

Found the answer.............

Needed to use a Global Temp table and that did it for me.

declare @sql varchar(4000)
set @sql ='Select * INTO ##TempTableName from #Test'

exec (@sql) 

Select * from ##TempTableName 

The ## is for a global temp table and that worked for me.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top