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)
 SP return values

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-04 : 15:11:32
SQLLess writes "Following is an example of a query which I use in a SP.

What I would really like to do is set both variables with one query. Can I get both data elements with one query, or do I have to run 2 queries to set 2 variables? This query is going to run over 2 servers and would like to save the extra trip.

set @int_MCID = (select top 1 iPID from customers inner join tblPersonnel on MtgConsultant = iPid where phone1 = @str_Phone and Position = 'Consultant')

set @int_LocID = (select top 1 iLocID from customers inner join tblPersonnel on MtgConsultant = iPid where phone1 = @str_Phone and Position = 'Consultant')

Select @int_LocID, @int_MCID"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2001-12-04 : 15:31:29
SELECT top 1 @int_MCID =iPID, @int_LocID=iLocID
FROM customers INNER JOIN tblPersonnel ON MtgConsultant = iPid
WHERE phone1 = @str_Phone AND Position = 'Consultant'

SELECT @int_LocID, @int_MCID


Go to Top of Page
   

- Advertisement -