标识符 |
31-03-2022_13636075 |
01-04-2022_13650262 |
04-04-04-2022_136663174 |
05-04-2022_13672025 |
xxxxx_ |
- |
在某些 |
部分 |
” |
值中 |
xx |
删除(仅)“ xx- SSI中的列,但没有影响没有此格式的值?例如,“ 21-05-2022_12345678” =“ 12345678”,但我不希望它们受影响的其他值。这只是此列中许多行的示例,因此我只希望那些具有这种格式的人。
SELECT REVERSE(substring(REVERSE('09-03-2022_13481330'),0,CHARINDEX('_',REVERSE('09-03-2022_13481330'),0)))
,但这也会影响其他值。此外,这是SSMS而不是SSIS中的,因为我不确定如何在SSIS代码中转换此表达式。
更新:SSIS中的校正代码如下:
(FINDSTRING(IDENTIFIER,"__-__-____[_]",1) == 1) ? SUBSTRING(IIDENTIFIER,12,LEN(IDENTIFIER) - 11) : IDENTIFIER
IDENTIFIER |
31-03-2022_13636075 |
01-04-2022_13650262 |
04-04-2022_13663174 |
05-04-2022_13672025 |
20220099001 |
11614491_R |
10781198 |
00000000000 |
11283627_P |
11614491_R |
-1 |
how can i remove (only) the "XX-XX-XXXXX_" Part in certain values of a column in SSIS but WITHOUT affecting values that doesn't have this format? For example "21-05-2022_12345678" = "12345678" but the other values i don't want them affected. This are just examples of many rows from this column so i want only the ones that have this format to be affected.
SELECT REVERSE(substring(REVERSE('09-03-2022_13481330'),0,CHARINDEX('_',REVERSE('09-03-2022_13481330'),0)))
but this also affects others values.Also this is in ssms not ssis because i am not sure how to transform this expression in ssis code.
Update : Corrected code in SSIS goes as following:
(FINDSTRING(IDENTIFIER,"__-__-____[_]",1) == 1) ? SUBSTRING(IIDENTIFIER,12,LEN(IDENTIFIER) - 11) : IDENTIFIER
发布评论
评论(1)
您可以访问SQL源吗?您可以通过使用喜欢的
在SQL上进行此操作,并使用单个Char Wildcard
_
请参见下面的示例,请参见喜欢 并使用单个char通配符,
如果您无法访问源SQL更棘手,因为您可能需要在脚本任务中使用Regex,或者可能有一个可以应用的表达式
Do you have access to the SQL source? You can do this on the sql by using a
LIKE
and crafting a match pattern using the single char wildcard_
please see below examplePlease see the Microsoft Documentation on LIKE and using single char wildcards
If you don't have access to the source SQL it gets a bit more tricky as you might need to use regex in a script task or maybe there is a expression you can apply