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)
 dynamic select statement

Author  Topic 

mgoodwin
Starting Member

2 Posts

Posted - 2003-05-09 : 04:44:34
Hi there,

I have written a dynamic sql statement which returns multiple values, I need to be using those values in another statement, so I want to store the returned values in a local variable.

I know how to do this with just one field returned, i.e.

select @localVar = max(p) from tbl

but for multiple values I can't get it working, what I would have liked to do is:

select @localVar_1, @localVar_2 = max(p), max(q) from tbl

Any pointers anyone??

thanks in advance..

Matt

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2003-05-09 : 05:16:38
select @localVar_1= max(p), @localVar_2 = max(q) from tbl

Go to Top of Page

mgoodwin
Starting Member

2 Posts

Posted - 2003-05-09 : 05:34:54
thanks for your help! that solved the problem :)

thanks again
Matt

Go to Top of Page
   

- Advertisement -