Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing values of dynamic select statements into a variable

Status
Not open for further replies.

ma77

Programmer
Dec 18, 2001
1
GB
A situation has arisen where I would like to be able to run the folloing kind of command.
I have to build the statement up in a string and execute it. I also have to pass the returned figure into a seperate variable.
Ideally I would like to be able to run :
select @value=exec(@SQLSTRING)

but this does not seem to be supported.

ANY IDEAS??
Cheers,
M@.
 
It creates a temporary table and of an insert of the result from the stored procedure. Example:

create proc test
as
set nocount on
select au_lname from pubs..authors
go

create table #test
(
au_lname varchar(40) not null
)

insert #test
exec test

select * from #test

I expect to have helped.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top