DECLARE @count int
SELECT @count = SUM(...) FROM table1 WHERE...
IF @count > 0
BEGIN
-- Do something here
END
use northwind
declare @thisrows int
select sum(unitprice) from [order details] where orderid=999999
set @thisrows=@@rowcount
print cast(@thisrows as nvarchar)
select IsNull(sum(unitprice), 0) from [order details] where orderid=999999