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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to get data from EXEC ?

Author  Topic 

HugoHiasl
Starting Member

4 Posts

Posted - 2004-08-11 : 03:29:33
Sorry for my beginner questions.

I'm moving to SQL Server from Oracle.

How can I get the data, which I retrieved with an EXEC Statement?

I have something like this:

@strSql = 'Select A_Test FROM T_Test'
EXEC(@strSql)

I found one information, that after the execution of the EXEC the variable @strSql should contain the value or the values of the table.

But it isn't. Can anybody give me please a hint how to step through the return values with a cursor or something similar ?

Thanks in advance
Oliver

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-08-11 : 05:57:51
you could do
DECLARE @strSql VARCHAR(50)
set @strSql = 'Select A_Test into ##tempTable FROM T_Test'
EXEC(@strSql)
select * from ##tempTable

and then do what you want with it...

Go with the flow & have fun! Else fight the flow :)
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2004-08-11 : 06:03:13
quote:
@strSql = 'Select A_Test FROM T_Test'
EXEC(@strSql)



What's wrong with

Select A_Test FROM T_Test

?

Why the dynamic sql?

-------
Moo. :)
Go to Top of Page
   

- Advertisement -