任何人都可以帮助以下实施......
CName Pan Mobile ------------------------ A PANA1 1234567891 B PANB2 1234567892
Pan_No Mobile_No CustomerName Gender ---------------------------------------- PANA1 1234567891 A M PANB2 1234567892 B F
Email Mobile_Number Customer_Name PanNumber ---------------------------------------------------- A@gmail.com 1234567891 A PANA1 B@gmail.com 1234567892 B PANB2
C_Name C_PanNo C_MobileNo --------------------------- A PANA1 1234567891 B PANB2 1234567892
Id DestinationColumnName ExternalHeaderName ----------------------------------------------- 1 C_Name CName 2 C_Name CustomerName 3 C_Name Customer_Name 3 C_PanNo Pan 4 C_PanNo Pan_No 5 C_PanNo PanNumber 6 C_MobileNo Mobile 7 C_MobileNo Mobile_No 8 C_MobileNo Mobile_Number
在上面的例子中,我需要构建一个SSIS包,它应该适用于上述所有三种情况 列的顺序已更改,并且正在添加新列。 在案例2&情况3它应该忽略性别和电子邮件列。
我是SSIS的新手,请帮助我如何用SSIS实现同样的效果..我知道它只能通过脚本组件实现 不知道怎么做......
答案 0 :(得分:0)
如果我愿意,我将使用脚本任务并使用以下逻辑。 (对不起,我不能写代码,但我可以给你整体的想法)..我不确定性能,但它100%工作......
Use “Script Task”
Output – c1, c2, c3 (assume output columns are fix)
Variable
@Headers = H1,H2,H3,H4 (get value from file like first row/header row)
@Columns_Object = Multiple row from Header mapping table
Row value should like:
1) C_Name |CName,CustomerName,Customer_Name
2) C_PanNo |PAN,Pan_No,Pan_Number
@Array_Header = @Headers splite using “,”
Now value is like
[0] = H1,
[1] = H2, etc
Use foreach loop @Array_Header
Pick one value “H1” and find Row from @Columns_Object
Once you get row find value before “|” (e.g get C_Name) store in local variable @SelectCol
Switch
{
If @SelectCol = ‘C_Name’
Then store into
Ouput C1 =datarow.col[0]
( “0” we get base on position of H1) if loop is looking for H2 then index is “1”
Else if @SelectCol = “C_PanNo”
Ouput C2 =datarow.col[1]
END
}