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 2005 Forums
 Transact-SQL (2005)
 value when no row returned on none aggregrate

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-03-24 : 11:54:18
Greetings,

When doing following query I might get no results. But I still want to set @CutArea to 0 . But I cannot do a COALESCE here because there are not rows coming back. Is there a simpler way of doing it other than what I plan to do that is
doing a EXISTS (SELECT * from VCutArea....with the bottom WHERE clause)


SELECT @CutArea = DefinitionValue
FROM dbo.VCutArea AS vca
WHERE vca.DefinitionDate = @CapacityPlanningDate
AND vca.BranchID = @BranchID
AND vca.CommodityID = @CommodityID

Thank you very much as always

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-24 : 12:00:47
[code]

set @CutArea=0
SELECT @CutArea = DefinitionValue
FROM dbo.VCutArea AS vca
WHERE vca.DefinitionDate = @CapacityPlanningDate
AND vca.BranchID = @BranchID
AND vca.CommodityID = @CommodityID[/code]
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-03-24 : 12:07:54
AHA!!!!! Thank you very much Saket Sinha
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-24 : 12:20:49
np
Go to Top of Page
   

- Advertisement -