hi,
how do i save result to parameter when using SP?
i have something like this
the problem is that it sometimes return NULL, i want to save the result to parameter and check if this parameter is null if so i will return 0Code:SELECT SUM(price) FROM employee WHERE employee_id = @EmployeeID
something like that:
i think i can do it like so...Code:DECLARE @SumPrice decimal SET @SumPrice = SELECT SUM(price) FROM employee WHERE employee_id = @EmployeeID IS NULL
but then i executing the query twice... (no good).... what is the best solution ?Code:IF SELECT SUM(price) FROM employee WHERE employee_id = @EmployeeID IS NULL BEGIN SELECT 0 END ELSE BEGIN SELECT SUM(price) FROM employee WHERE employee_id = @EmployeeID IS NULL END
thanks!


If you Like it 
Reply With Quote
