MASK_PARTIAL()
MASK_PARTIAL() — Converts the inner characters of a string to a mask value.
Synopsis
MASK_PARTIAL( string-expression, leading-characters, trailing-characters [, mask-character] )
Description
The MASK_PARTIAL() function returns the specified string expression with all but the first
leading-characters and last trailing-characters characters replaced by
the character mask-character. For instance, the output of MASK_PARTIAL('VoltActiveData', 2, 4,
'X') is the string 'VoXXXXXXXXData', where all but the first two and last four characters are
masked. The default value for the optional argument mask-character is *. To mask only the outer
characters of a text string, use MASK_OUTER().
Note that MASK_INNER() has the same utility as MASK_PARTIAL() except with default mask character X.
Example
The following example anonymizes the results of a SELECT expression by using the MASK_PARTIAL() function to replace all but the first three and last two digits of each phone number with asterisks.
SELECT last_name, MASK_PARTIAL(phone_number, 3, 2), email, city, state FROM contestants ORDER BY last_name ASC;
Documentation