如何在ssis包中动态替换指定列中的*?

时间:2014-10-27 05:14:25

标签: ssis

我有一个Excel源代码,其中一个列名为Emailid

我想要输出如下例:

'mahesh123@gmail.com'

输出应为

'ma*****23@gmail.com'

作为初学者,我正在搜索SSIS包中的函数STUFF的替换...

select 
substring(studentEMAILIDid,1,2)
+ replicate('*',len(substring(studentEMAILIDid,1,
       charindex(studentEMAILIDid,'@')
  -1‌​)-4) 
+ substring(studentEMAILIDid,charindex(studentEMAILIDid,'@')-2,2) 
+ substring(studentEMAILIDid,charindex(studentEMAILIDid,'@')+1,
len(studentEMAILIDi‌​d) 
from <tablename>

我在SSMS中尝试了上面的代码,我希望通过SSIS包得到结果而不使用&#34;执行SQL任务&#34;。

这是我试过的表达式:

emailid==
substring(
    StudentEMailID,
    3,
    LEN(right(StudentEMailID,
       findstring('@',Stud‌​entEMailID + '@')-1
       )
    )-4,
    REPLICATE('*',LEN(LEFT(StudentEMailID,
    findstring('@',StudentEMailID + '@')-1))-4)) 
    – 

1 个答案:

答案 0 :(得分:0)

数据:

select N'mahesh123@gmail.com' as email
union all
select N'EmpireAgain@gmail.com'

派生列代码:

SUBSTRING(email,1,2) + 
REPLICATE("*",LEN(email) - FINDSTRING(email,"@",1) - 4) + 
SUBSTRING(email,FINDSTRING(email,"@",1)-2,LEN(email)-(FINDSTRING(email,"@",1)-2) + 1)

结果:

email                   NewEmail
mahesh123@gmail.com     ma*****23@gmail.com
EmpireAgain@gmail.com   Em*****in@gmail.com