SSIS如何使用派生列通过分隔符获取字符串的一部分 [英] SSIS How to get part of a string by separator using Derived Column

查看:13
本文介绍了SSIS如何使用派生列通过分隔符获取字符串的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试编写一个 SSIS 表达式以获取分隔符之前字符串的正确部分,然后将新字符串放入新列中.我在派生列中使用了 Substring 和 Findstring,但我遇到了问题.

I trying to write an SSIS expression to get the right part of a string before the separator and then put the new string in a new column. I have used Substring and Findstring in derived column but I am having trouble.

Company
Virgin Altantic - F30008 
Google - F38115

我需要检索 F30008 和 F38115.

I need to retrieve F30008 and F38115.

我用了这个表达:

(DT_STR,65,1252)(FINDSTRING(Company,"- ",1) != 0 ? (SUBSTRING(Company,1,FINDSTRING(Company,"-",1) + 2)) :公司)

从这个表达我得到:

Company
Virgin Altantic - 
Google - 

推荐答案

数据:

|                    COMPANY |
|----------------------------|
|   Virgin Altantic - F30008 |
|            Google - F38115 |
| Google youtube - F38115169 |

派生列代码:

NewColumn1

SUBSTRING(Company,1,LEN(Company) - FINDSTRING(REVERSE(Company),"-",1) - 1)

NewColumn2

SUBSTRING(Company,LEN(Company) - FINDSTRING(REVERSE(Company),"-",1) + 3,FINDSTRING(REVERSE(Company),"-",1) - 2)

结果:

这篇关于SSIS如何使用派生列通过分隔符获取字符串的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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