我的数据类似于以下内容:
"D.STEIN","DS","01","ALTRES","TTTTTTFFTT"
"D.STEIN","DS","01","APCASH","TTTTTTFFTT"
"D.STEIN","DS","01","APINH","TTTTTTFFTT"
"D.STEIN","DS","01","APINV","TTTTTTFFTT"
"D.STEIN","DS","01","APMISC","TTTTTTFFTT"
"D.STEIN","DS","01","APPCHK","TTTTTTFFTT"
"D.STEIN","DS","01","APWLNK","TTTTTTFFTT"
"D.STEIN","DS","01","ARCOM","TTTTTTFFTT"
"D.STEIN","DS","01","ARINV","TTTTTTFFTT"
我需要将最终字符串分成单独的列以导入到SQL表中,每个字段一个字母。因此,“TTTTTTFFTT”将分为10个单独的字段,每个字段具有单个位值。
我使用平面文件源编辑器加载数据。我如何完成拆分?
答案 0 :(得分:3)
使用派生列任务。在那里,使用
行中的表达式为您想要的每个字段创建一个新列substring([ColumnName],1,1) == "T" ? 1 : 0
所以这基本上是第一个字符的条件,如果它是T然后使它为1,否则为0 ...为你的字段中的每个字母执行此操作。使数据类型为布尔值(DT_BOOL)。
答案 1 :(得分:0)
我不知道SSIS。但也许你可以进行这样的转换,每个位列都有一个转换:
case substring(Field5, 1, 1) when 'T' the 1 else 0 end
case substring(Field5, 2, 1) when 'T' the 1 else 0 end
case substring(Field5, 3, 1) when 'T' the 1 else 0 end
...
如果位列不可为空,则可能需要执行以下操作:
isnull(case substring(Field5, 1, 1) when 'T' the 1 else 0 end, 0)