I get the message above when I try to run the following stored procedure. The error occurs in the last line of the procedure.
CREATE PROCEDURE calc_SlabCullTons_Mill
(
@MillID int,
@DateFrom datetime,
@DateTo datetime,
@CullSlabs decimal(16,3) OUTPUT
)
AS
SET NOCOUNT ON
SET @CullSlabs = (SELECT CAST(SUM(Pounds) as dec(16,3)) FROM Cull C
INNER JOIN GlobalSupport2.dbo.CullCode CC ON C.CullCodeID = CC.CullCodeID
INNER JOIN GlobalSupport2.dbo.CullCategory CCC ON CC.CullCategoryID = CCC.CullCategoryID
WHERE C.MillID = @MillID AND C.DateProduction >= @DateFrom AND C.DateProduction <= @DateTo AND CCC.CullCategoryNbr = '826' )
SET @CullSlabs = CAST(ISNULL(@CullSlabs, 0) as decimal(16,3)) / 2000.0
I've tried excluding the CAST statement as well as including the entire calculation in it.
I am stumped. Any help would be greatly appreciated!
CREATE PROCEDURE calc_SlabCullTons_Mill
(
@MillID int,
@DateFrom datetime,
@DateTo datetime,
@CullSlabs decimal(16,3) OUTPUT
)
AS
SET NOCOUNT ON
SET @CullSlabs = (SELECT CAST(SUM(Pounds) as dec(16,3)) FROM Cull C
INNER JOIN GlobalSupport2.dbo.CullCode CC ON C.CullCodeID = CC.CullCodeID
INNER JOIN GlobalSupport2.dbo.CullCategory CCC ON CC.CullCategoryID = CCC.CullCategoryID
WHERE C.MillID = @MillID AND C.DateProduction >= @DateFrom AND C.DateProduction <= @DateTo AND CCC.CullCategoryNbr = '826' )
SET @CullSlabs = CAST(ISNULL(@CullSlabs, 0) as decimal(16,3)) / 2000.0
I've tried excluding the CAST statement as well as including the entire calculation in it.
I am stumped. Any help would be greatly appreciated!