Link to home
Start Free TrialLog in
Avatar of mahmood66
mahmood66Flag for United Arab Emirates

asked on

Float in RaiseError

how to display the variable of float type in Raiserror statement in sqlsver,
see my below code.

--in below select state, i have added only fQtyLastProcess
                  Select @cLotNo = cLotNumber,@fQtyLastProcess = fQtyLastProcess From _btblInvoiceLines
                  Where iInvoiceID in ( Select AutoIndex From Inserted Where DocFlag <> 2)
--Add by Ramzan following block is added
                  SELECT    @fQtyExisting= isnull(sum(dbo._etblLotTrackingQty.fQtyOnHand),0) FROM dbo._etblLotTracking INNER JOIN
            dbo._etblLotTrackingQty ON dbo._etblLotTracking.idLotTracking = dbo._etblLotTrackingQty.iLotTrackingID
                  WHERE     (dbo._etblLotTracking.cLotDescription <> 'OPENING') AND (dbo._etblLotTrackingQty.fQtyOnHand <> 0) and cLotDescription = @cLotNo
                  if ((@fQtyLastProcess + @fQtyExisting)>30)
                  Begin
                        raiserror('Qty Cannot be More than 30MT. in %d',16,1,Convert(VARCHAR(10), @fQtyLastProcess))
                  end
--end by Ramzan
my raiserror statement is giving error.
ASKER CERTIFIED SOLUTION
Avatar of halfbloodprince
halfbloodprince

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dshrivallabh
dshrivallabh

Write RAISERROR('Qty Cannot be More than 30MT. in ' + CONVERT(VARCHAR(10),CONVERT(numeric(16,3),@fQtyLastProcess)))
Avatar of Shannon_Lowder
I hate to be the bearer of bad news, but floats cannot be used for the Argument parameter.  Only tinyint, smallint, int, char, varchar, nchar, nvarchar, binary, or varbinary can be used.  But I think you might be able to try this workaround:

---
Shannon Lowder
Database Engineer
http://toyboxcreations.net
--try this:
DECLARE @varchar_fQtyLastProcess VARCHAR(10)
SET @varchar_fQtyLastProcess = CONVERT(VARCHAR(10), @fQtyLastProcess)
RAISERROR('Qty Cannot be More than 30MT. in %s',16,1,@varchar_fQtyLastProcess)

---in place of 
 raiserror('Qty Cannot be More than 30MT. in %d',16,1,Convert(VARCHAR(10), @fQtyLastProcess))

Open in new window