cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion failed when converting the nvarchar value 'YES' to data type int

former_member229757
Participant
0 Kudos

Hi Experts,

while executing the below query error showing.

"Conversion failed when converting the nvarchar value 'YES' to data type int"

SELECT T0.[DocEntry]
,T0.[DocNum]
,T0.[DocDate]
, T0.[CardCode]
, T0.[CardName]
,T0.[Comments]
, T0.[DocTotal]
, T0.[DocTotal] - T0.[VatSum] AS 'Sales Value'
, T0.[DocTotal] - T0.[VatSum] - T0.[GrosProfit] AS 'Purchase Costs'
,CASE
WHEN T0.[U_Airfrieght] IS NULL THEN 0
ELSE T0.[U_Airfrieght]
END AS 'Air frieght'
,CASE
WHEN T0.[U_InlandCharges] IS NULL THEN 0
ELSE T0.[U_InlandCharges]
END AS 'Inland Charges'
,CASE
WHEN T0.[U_Duty] IS NULL THEN 0
ELSE T0.[U_Duty]
END AS 'Duty'
, T0.[DocTotal] - T0.[VatSum] - T0.[GrosProfit] +
CASE
WHEN T0.[U_Airfrieght] IS NULL THEN 0
ELSE T0.[U_Airfrieght]
END
+ CASE
WHEN T0.[U_InlandCharges] IS NULL THEN 0
ELSE T0.[U_InlandCharges]
END
+ CASE
WHEN T0.[U_Duty] IS NULL THEN 0
ELSE T0.[U_Duty]
END
AS 'Total Costs'
, T0.[GrosProfit] -
CASE
WHEN T0.[U_Airfrieght] IS NULL THEN 0
ELSE T0.[U_Airfrieght]
END
- CASE
WHEN T0.[U_InlandCharges] IS NULL THEN 0
ELSE T0.[U_InlandCharges]
END
- CASE
WHEN T0.[U_Duty] IS NULL THEN 0
ELSE T0.[U_Duty]
END
AS 'Gross Profit'

FROM OINV T0 WHERE T0.[DocDate] between '10-01-2021' and '10-31-2021'

edayang
Advisor
Advisor
0 Kudos

What is the product you have implemented this query?

Thanks,

Eda

Accepted Solutions (0)

Answers (1)

Answers (1)

jitin_chawla
Advisor
Advisor

Hi,

Its seems that certain nvarchar field value is included in your formula to be a Data type.

Check for fields (may be UDF's) where value is YES.

kr,

Jitin