Link to home
Start Free TrialLog in
Avatar of tommym121
tommym121Flag for Canada

asked on

SQL - How to make table result available to the calling script

I have to execut this statement, it will return result as a table.  How can I make use of it
EXEC ('select ' + @columnsList + ',  '+ @SQLValuesSetTemplate + 'as ValueSet From ' + @sourceTable)
ASKER CERTIFIED SOLUTION
Avatar of Saurabh Bhadauria
Saurabh Bhadauria
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tommym121

ASKER

saurv

I try, I can not get it working. Would you be able to look at it what is missing?


DECLARE @str varchar(max)
Set @str=
'Select * from T1'
insert into #tempTable123
Exec (@str)
Print 'Hello' ;

Select * from #tempTable123

I got this error
Msg 208, Level 16, State 0, Line 5
Invalid object name '#tempTable123'.
Thanks