本文介绍了将nvarchar值'1819000030-1'转换为数据类型int时转换失败。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 声明@DocEntry nVarchar(10) SET @DocEntry =(SELECT转换(nVarchar,Max(U_DocNum),112)FROM [@TI_GoodReceipt]) 选择T1.DocDate,T1.DocNum,T1.docentry,t1.CardName,T3.expdate,T1.NumAtCard,T3.notes,T0.BatchNum,T0。数量, T3.DistNumber,t2.WhsCode,t2.U_IsInsp,T2.ItemCode,t2.Dscription,T1.U_BOENO,T2.unitMsr来自IBT1 T0 left Join OPDN T1 On T0.BaseType = T1.ObjType 和T0.BaseEntry = T1.DocEntry 内部联接pdn1 T1上的T2.DocEntry = t2.DocEntry和T0.quantity <> t2.quantity 左外连接obtn T3 on T0.BatchNum = T3.AbsEntry 其中T1.DocEntry = '30' 我尝试了什么: 请帮助我解决此错误Declare @DocEntry nVarchar(10)SET @DocEntry = (SELECT Convert(nVarchar,Max(U_DocNum),112) FROM [@TI_GoodReceipt])Select T1.DocDate,T1.DocNum,T1.docentry,t1.CardName,T3.expdate,T1.NumAtCard,T3.notes,T0.BatchNum,T0.Quantity,T3.DistNumber,t2.WhsCode,t2.U_IsInsp,T2.ItemCode,t2.Dscription,T1.U_BOENO,T2.unitMsr From IBT1 T0left Join OPDN T1 On T0.BaseType=T1.ObjTypeand T0.BaseEntry=T1.DocEntryinner join pdn1 T2 on T1.DocEntry =t2.DocEntry and T0.quantity <> t2.quantityleft outer join obtn T3 on T0.BatchNum = T3.AbsEntry where T1.DocEntry = '30'What I have tried:Please help me on this query error推荐答案查看错误消息:Look at the error message:Conversion failed when converting the nvarchar value '1819000030-1' to data type int.这不是一个整数,所以当SQL试图转换它时它会失败。 为什么不是整数? Dunno - 毕竟这是你的数据,我们无法访问它。 所以首先要找出价值'1819000030-1'的来源,然后你可以开始计算出哪个部分您的查询正在尝试转换它。然后你可以决定是否存在表格设计错误,数据错误或查询错误。 但是我们不能为你做到这一点 - 我们没有完全访问您的数据!It's not an integer, so when SQL tried to convert it it fails.Why isn't it an integer? Dunno - it's your data after all and we have no access to it.So start by finding out where the value '1819000030-1' is coming from, and then you can start working out which part of your query is trying to convert it. Then you can decide if there is a table design error, a data error, or a query error.But we can't do that for you - we have no access to your data at all! Quote:转换nvarchar值时转换失败'1819000030- 1'到数据类型int。Conversion failed when converting the nvarchar value '1819000030-1' to data type int. 因为'1819000030-1'不是整数,' - '只允许在第一个位置用于负数。 对每个人都应该是显而易见的。Bacause '1819000030-1' is not an integer, '-' is allowed only in first position for negative numbers.It should be obvious to everyone. 这篇关于将nvarchar值'1819000030-1'转换为数据类型int时转换失败。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-30 05:49