检查列值是否为数字.安全信息系统 [英] Check if column value is Numeric. SSIS

查看:29
本文介绍了检查列值是否为数字.安全信息系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一列数据类型为 varchar.我想用 NULL 替换所有不是数字的值.

I have a column with datatype of varchar. I would like to replace all the values that are not numeric with NULL.

例如,我的列可以包含 MIGB_MGW1352 的值.我在 Derived Column Transformation Editor 中使用的当前表达式是:

So for example my column can contain a value of MIGB_MGW but also 1352. The current expression I am using with Derived Column Transformation Editor is:

(DT_I4)kbup == (DT_I4)kbup ? 1  : 0

当然,这替换了我想用 1 保留的所有值.我将使用什么表达式来保留数值?(在本例中为 1352)

But of course this replaces all the values I want to keep with 1. What expression would I use to keep the numeric values? (1352 in this example)

推荐答案

如果你想要一个 varchar 类型的 null,你可以使用 NULL(DT_STR).对于 DT_I4,您可以使用 NULL(DT_I4) 等.

If you want a null of varchar type, you can use NULL(DT_STR). For a DT_I4 you can use NULL(DT_I4) etc.

然后您可以使用 (DT_I4)kbup 代替您的 1 来返回您想要保留、转换的原始 varchar 值到 DT_I4:

You can then use (DT_I4)kbup in place of your 1 to return the original varchar value that you want to keep, converted to a DT_I4:

(DT_I4)kbup == (DT_I4)kbup ? (DT_I4)kbup : NULL(DT_I4)

这篇关于检查列值是否为数字.安全信息系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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