ssis数据转换和null处理

发布于 2024-12-11 22:00:04 字数 120 浏览 1 评论 0原文

我从 Excel 电子表格中提取数据,并使用数据转换组件将数据转换为相关类型。我正在测试这个包,并注意到如果数据转换组件尝试转换的值为空,则它不会重定向行。这是正确的吗?在这种情况下我该如何处理空值。我应该检查堆栈上的空值吗?

Im pulling in data from an excel spreadsheet and using a data conversion component to convert the data to the relevant types. Im testing this package and have noticed that the data conversion coomponent does not redirect a row if the value it is trying to convert is null. Is this correct? How can i handle nulls in this situation. Should i check for nulls further up the stack?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜扑 2024-12-18 22:00:04

当输入数据为无效的。可以将其视为 CAST(NULL AS char(10)) 或数据类型的 tsql 等效项。该转换应该始终成功,NULL 可以是任何数据类型。

转换的错误输出仅处理两类转换失败:错误(类型不兼容)和截断。

如果希望不允许字段中存在空值,我会在数据流中的某个位置使用条件分割来过滤掉这些行

NULL 值的快速演示不影响数据转换转换

在 OLE DB 源中,我发送了一行空值改变数据类型

SELECT
    CAST(NULL AS int) AS null_int
,   CAST(NULL AS varchar(10)) AS null_varchar
,   CAST(NULL AS nchar(5)) AS null_nchar
,   CAST(NULL AS decimal(5,4)) AS null_decimal

在此处输入图像描述

在数据转换中,我尝试使用安全的东西(int 到 nvarchar)以及那些曾经的事情不太如此(nchar 到布尔值)
在此处输入图像描述

The Data Conversion Transformation doesn't error out when the input data is null. Think of it much like as the tsql equivalent of CAST(NULL AS char(10)) or data type. That conversion should always succeed, NULL can be any data type.

The error output for the transformation only handles two categories of conversion failure: error (incompatible type) and truncation.

If the desire is to not allow nulls in fields, I'd use conditional splits somewhere in your data flow to filter out those rows

Quick demo of NULL values not affecting Data Conversion Transformation

In an OLE DB source, I sent a row of nulls with varying data types out

SELECT
    CAST(NULL AS int) AS null_int
,   CAST(NULL AS varchar(10)) AS null_varchar
,   CAST(NULL AS nchar(5)) AS null_nchar
,   CAST(NULL AS decimal(5,4)) AS null_decimal

enter image description here

In the data conversion, I tried it with things that were safe (int to nvarchar) and things that were less so (nchar to to boolean)
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文