MASK_TEXT()
MASK_TEXT() — Converts the trailing characters of a string to a mask value.
Synopsis
MASK_TEXT( string-expression [, mask-character [, leading-characters]] )
Description
The MASK_TEXT() function returns the specified string expression with all but the first
leading-characters characters replaced by the character mask-character. For
instance, the output of MASK_TEXT('VoltActiveData', '*', 4) is the string
'Volt**********', where only the first four characters are not masked. The default values for the
optional arguments mask-character and leading-characters are * and 1,
respectively. To mask specific kinds of text strings, such as email addresses or credit card numbers, there are specialized
functions such as MASK_EMAIL() and MASK_CCN().
Example
The following example anonymizes the results of a SELECT expression by using the MASK_TEXT() function to replace all but the first letter of the contestant's last name with asterisks.
SELECT first_name, MASK_TEXT(last_name) AS last, city, state FROM contestants ORDER BY last ASC, first_name ASC;
Documentation