Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How use Dynamic sql table results forward?

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2011-12-02 : 20:32:28

set @dynsql = 'create table #temp(col1, col2) insert into #temp select col1, col2 from openrowset(...,
where col1=' + @variable ...'

exec @dynsql

In the above example, how would I get the table row from #temp table? Is it feasible?

I've tried some variation and no luck. In essence I want to use the results from exec dynsql where the table created in the dynamic has rows and put them in a table that i can keep using down the line.

Thanks!!

--PhB

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-02 : 20:54:33
create the temp table outside of dynamic SQL


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2011-12-03 : 11:21:54
YES!! Thanks!


--PhB
Go to Top of Page
   

- Advertisement -