[英]Conditional Split in SSIS based on the number of times a character appears in a string
I would like to split the flow of data based on the number of times a particular character appears in a string. 我想根据特定字符在字符串中出现的次数来分割数据流。
Source Data:
R1 - 123@abc.com
R2 - 567@stu.com
R3 - 234@fgh.com,456@xyz.com
R4 - 567@wxy.com,789@pqr.com
R5 - 678@def.com
As seen above, 2 of the four records contain the "@" symbol twice. 如上所示,四个记录中的两个包含两次“@”符号。 I want to split data based on the number of times this character appears in a line
我想根据此字符出现在一行中的次数来分割数据
Expected result
Flat_File_Once (3 rows)
R1 - 123@abc.com
R2 - 567@stu.com
R3 - 678@def.com
Flat_File_Twice (2 rows)
R1 - 234@fgh.com,456@xyz.com
R2 - 567@wxy.com,789@pqr.com
This works in SQL, not sure how to do it in SSIS 这适用于SQL,不知道如何在SSIS中执行此操作
len(email) - len(replace(email, '@', '')) > 1
It's virtually the same formula except we'll use double quotes instead of single quotes 它实际上是相同的公式,除了我们将使用双引号而不是单引号
LEN([email]) - LEN(REPLACE([email], "@", ""))
That expression generates the total number of instances of the @ character. 该表达式生成@字符的实例总数。 Clever approach, I probably would have gotten bogged down trying to use
FINDSTRING
聪明的方法,我可能会陷入困境,试图使用
FINDSTRING
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.