cancel
Showing results for 
Search instead for 
Did you mean: 

Arithmetic overflow error converting expression to data type nvarchar. 'Company Info' (CINF) (CINF)

former_member752334
Discoverer
0 Kudos

hello Expert i am facing the above error while executing below stored procedure in transaction notification.

IF @transaction_type = 'A' AND @object_type = '13'

BEGIN

DECLARE @FreInv NVARCHAR SET @FreInv = (SELECT ((((T1.DocTotal+T1.DiscSum)-T1.RoundDif) *.7/100) + T1.RoundDif)

FROM OINV T1 WHERE T1.DocEntry=@list_of_cols_val_tab_del )

If exists (SELECT T0.DocEntry FROM OINV T0 Inner Join INV1 T2 On T0.DocEntry=T2.DocEntry

WHERE @FreInv < '0.00' AND T0.DocEntry=@list_of_cols_val_tab_del)

Begin

SET @error = 122 SET

@error_message = 'Test Error'

End

End

Accepted Solutions (1)

Accepted Solutions (1)

Johan_H
Active Contributor

Hi Ali,

If you are calculating a numerical value:

SET @FreInv = (SELECT ((((T1.DocTotal+T1.DiscSum)-T1.RoundDif) *.7/100) + T1.RoundDif)

and later making a numerical comparison:

WHERE @FreInv < '0.00'

then why are you using a text type?

DECLARE @FreInv NVARCHAR

Please check the numerical type of the OINV.DocTotal field, and apply it to the @FreInv variable, instead of NVARCHAR. Also change the comparison to:

WHERE @FreInv < 0

Regards,

Johan

former_member752334
Discoverer

Thanks Johan :

i have change the below and now its working good .

Thanks a lot Brother

DECLARE @FreInv Numeric

Answers (0)