Hi Steffi,
Above SQL doesnt fetch email address to do the string manipulation.
The Source SQL can be more simpler as below,
select mskey, searchvalue from idmv_value_basic with(nolock) where attrname = 'MX_MAIL_PRIMARY'
Destination tab be like,
MSKEYVALUE = %MSKEYVALUE%
changetype = Modify
MX_MAIL_PRIMARY = $FUNCTION.z_change_mail_address(%searchvalue%)$$
Note: make sure you check "Use Identity Store" check box in source tab and select appropriate IDS.
Kind regards,
Jai