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
 SQL Server Development (2000)
 Set multiple variables

Author  Topic 

jrockfl
Posting Yak Master

223 Posts

Posted - 2006-06-08 : 14:29:04
Let's say I have
DECLARE @CostYTD Decimal
DECLARE @CostPTD Decimal

Can I set both of these variables at the same time?
SELECT SUM(CostYTD) As CostYTD, SUM(CostPTD) AS CostPTD
FROM Table


Instead of doing..
SET @CostYTD =
(
SELECT SUM(CostYTD) As CostYTD
FROM Table
)

SET @CostCostPTD =
(
SELECT SUM(CostCostPTD) As CostCostPTD
FROM Table
)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-06-08 : 14:29:58
SELECT @CostYTD = SUM(CostYTD), @CostPTD = SUM(CostPTD)
FROM Table

Tara Kizer
aka tduggan
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 2006-06-08 : 14:32:45
Thanks Tara for the quick reply!
I love this web site, I have responses before I even finish posting my question!
Go to Top of Page
   

- Advertisement -