Also, stored procedure can only return integers as return codes.Either make use of an output parameter like thisCREATE PROCEDURE ASP_AccountBalance( @clientID INT, @balance FLOAT OUT)ASSET NOCOUNT ONDECLARE @BB FLOAT, @PM FLOAT, @INV FLOATSELECT @BB = ABS(SUM(beginningBalance))FROM tblClientsWHERE clientID = @clientIDSELECT @PM = ABS(SUM(amtPaid))FROM tblPaymentsWHERE clientNo = @clientIDSELECT @INV = ABS(SUM(totalDue))FROM tblInvoiceHdrWHERE clientID = @clientID AND [status] <> 'Void'SET @balance = @BB + @INV - @PM
Or better use a function like thisCREATE FUNCTION ASP_AccountBalance( @clientID INT)RETURNS FLOATASBEGIN DECLARE @BB FLOAT, @PM FLOAT, @INV FLOAT SELECT @BB = ABS(SUM(beginningBalance)) FROM tblClients WHERE clientID = @clientID SELECT @PM = ABS(SUM(amtPaid)) FROM tblPayments WHERE clientNo = @clientID SELECT @INV = ABS(SUM(totalDue)) FROM tblInvoiceHdr WHERE clientID = @clientID AND [status] <> 'Void' RETURN @BB + @INV - @PMEND
E 12°55'05.63"N 56°04'39.26"