从一列中提取字符并将其填充到两个不同的列ssis派生列中

时间:2018-05-24 23:26:06

标签: sql-server ssis etl ssis-2012

我有一个ProductDetails列,其中包含

等值
j Jameson Mbc 6.5, abc 8 abc blah
Napa california Mbc 1 abc 3.5
Washington k Mbc 2.5 abc 6
New york city is awesome

我有数千条记录

我想填充其他2列Mbc和abc,如下所示

Mbc
6.5
1
2.5

abc
8
3.5
6

我尝试了(DT_STR,10,1252)substring(ProductDetails, findstring(“Mbc”, ProductDetails,1)+4,3)

对于abc = (DT_STR,10,1252)substring(ProductDetails, findstring(“abc”, ProductDetails,1)+4,3)

我得到了结果,有些值会以1C2b等形式出现,只是想要数字没有字符

对于列值,例如 New york city is awesome我们只想填充Null

由于

1 个答案:

答案 0 :(得分:2)

“abc”专栏

FINDSTRING( [ProductDetails],"abc", 1 ) > 0 ? SUBSTRING(SUBSTRING([ProductDetails], FINDSTRING( [ProductDetails],"abc", 1 ) + 4 , 3),1,LEN( SUBSTRING([ProductDetails], FINDSTRING( [ProductDetails],"abc", 1 ) + 4 , 3) ) - FINDSTRING( SUBSTRING([ProductDetails], FINDSTRING( [ProductDetails],"abc", 1 ) + 4 , 3) ," ",1)) : NULL(DT_WSTR,50)

“Mbc”专栏

FINDSTRING( [ProductDetails],"Mbc", 1 ) > 0 ? SUBSTRING(SUBSTRING([ProductDetails], FINDSTRING( [ProductDetails],"Mbc", 1 ) + 4 , 3),1,LEN( SUBSTRING([ProductDetails], FINDSTRING( [ProductDetails],"Mbc", 1 ) + 4 , 3) ) - FINDSTRING( SUBSTRING([ProductDetails], FINDSTRING( [ProductDetails],"Mbc", 1 ) + 4 , 3) ," ",1)) : NULL(DT_WSTR,50)