查询中的转换错误 [英] conversion error in query

查看:59
本文介绍了查询中的转换错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

转换(int,T0.U_INRPRICE)结果





尝试转换时给出以下错误



将nvarchar值'82,236.44'转换为数据类型int时转换失败。



请咨询新的sql。



thx提前

convert (int, T0.U_INRPRICE ) as result


when try to convert it give below error

Conversion failed when converting the nvarchar value '82,236.44' to data type int.

pls advice hence new to sql.

thx in advance

推荐答案

错误信息非常明显:

The error message is pretty obvious:
Conversion failed when converting the nvarchar value '82,236.44' to data type int.



82,236.44不是整数值。



问题是您遇到了设计错误:您的数据库包含存储在基于字符串的列中的数值(或具有相同问题的多个列)。

解决方案是创建一个具有正确数据类型的新表,并编写一些C#或VB(或其他)代码,以便在您整理出来之前将现有数据转换并移动到新表中,然后再替换旧表插入其中的代码。



否则这个问题会一次又一次又一次地再次出现......而且你要把它留下的时间越长越好您需要纠正的数据增加 - 并且您能够计算出正确值的机会减少。


82,236.44 isn't an integer value.

The problem is that you have a design error: your database contains numeric values which you have stored in a string based column (or several columns with the same problem).
The solution is to create a new table, with the correct datatypes, and write some C# or VB (or whatever) code to convert and move your existing data into the new table before replacing the old one once you have sorted out the code which inserts into it.

Otherwise this problem will come back, again, and again, and again...and it gets harder to sort out the longer you leave it as the size of the data you need to correct increases - and the chances of you being able to work out the correct values decreases.


这篇关于查询中的转换错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆