Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
SELECT DISTINCT 
                      T0.Jobcard, T0.Operator, T1.JobCardQty, T0.Mouldqty, T0.Process, T0.Profilename, T0.Remark, T0.Date, T1.U_od, T0.Supervisor, T2.SizeFrom, 
                      T2.SizeTo, (T0.Mouldqty * T2.Rate + T2.DieSetting) AS Cost, T3.Division
FROM         SAPProduction.ProductionData AS T0 INNER JOIN
                      SAPProduction.RateChartData AS T1 ON T0.Jobcard = T1.Jobcard COLLATE SQL_Latin1_General_CP850_CI_AS INNER JOIN
                      SAPProduction.ProductionRateTable AS T2 ON T0.Process = T2.Process INNER JOIN
                      SAPProduction.ProductionMaterialMaster AS T4 ON T2.Process = T4.process INNER JOIN
                      SAPProduction.ProductionDivisionMaster AS T3 ON T2.ChartType = T3.fid
WHERE     (T1.U_od BETWEEN T2.SizeFrom AND T2.SizeTo)
Posted
Updated 28-Nov-12 6:40am
v2

Find what the data type is for these columns:
T0.Mouldqty
T2.Rate
T2.DieSetting
T2.ChartType
T3.fid
T1.U_od
T2.SizeFrom
T2.SizeTo

If T2.ChartType = T3.fid either are a numeric change it to character (I suspect ChartType is character and fid is not)
SQL will try and make characters into a numeric if used in combination with a numeric.

Since T0.Mouldqty * T2.Rate + T2.DieSetting is an equation if any are not a numeric type use the CAST or CONVERT function.

If any T1.U_od BETWEEN T2.SizeFrom AND T2.SizeTo are character I would change to numeric.
 
Share this answer
 
what you have store in nvarchar if its some kind of number then only it can be converted into numeric else so error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900