简体   繁体   English

SSIS将NVARCHAR转换为Int

[英]SSIS Convert NVARCHAR to Int

I need a solution to convert list of nvarchar to int (or numerical). 我需要一种将nvarchar列表转换为int(或数字)的解决方案。

Input number is range of 0-10 or null and its a null value not null string. 输入数字的范围是0-10或null,并且其null值而不是null字符串。

On SSIS I have an OLE DB Source with this information which is then passed into a data conversion where this field is alterd to numeric (DT_NUMERIC), the destination table is set to receive an int however I always get the below error 在SSIS上,我有一个带有此信息的OLE DB源,然后将其传递到数据转换中,该字段将字段更改为数字(DT_NUMERIC),目标表设置为接收int,但是我总是收到以下错误

"Data conversion failed while converting column Range to column numRange.The value could not be converted because of a potential loss of data" “将列范围转换为列numRange时数据转换失败。由于潜在的数据丢失,无法转换该值”

I can ignore this and everything seems to work fine but I would rather either handle the error or figure out what's causing it, with this input data what is the issue? 我可以忽略这一点,并且一切似乎都可以正常工作,但是我宁愿处理错误还是弄清楚是什么原因,使用此输入数据是什么问题?

In a derived column component create a new column with expression as: (DT_I4)[Nvarchar column name]. 在派生的列组件中,创建一个新列,其表达式为:(DT_I4)[Nvarchar列名]。

Also, configure the error op to redirect row so that any failed conversions can be captured and fixed. 另外,将错误操作配置为重定向行,以便可以捕获和修复所有失败的转换。

Refer to link : https://social.msdn.microsoft.com/Forums/en-US/705fa9a1-b7bc-402b-90cd-9ab67a278cff/converting-nvarchar-to-an-int-int-ssis?forum=sqlintegrationservices 请参阅链接: https : //social.msdn.microsoft.com/Forums/en-US/705fa9a1-b7bc-402b-90cd-9ab67a278cff/converting-nvarchar-to-an-int-int-ssis?forum=sqlintegrationservices

https://social.technet.microsoft.com/Forums/sqlserver/en-US/baaecc68-54a2-496c-81a4-4cb4e897a9dc/convert-nvarchar-to-integer-in-sql-server?forum=sqldataaccess https://social.technet.microsoft.com/Forums/sqlserver/en-US/baaecc68-54a2-496c-81a4-4cb4e897a9dc/convert-nvarchar-to-integer-in-sql-server?forum=sqldataaccess

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM