What built-in masking functions are available in SQL Server for dynamic data masking?
Short answer
SQL Server provides several built-in masking functions including default, which fully hides a value based on its data type, email, which partially masks an email address, random, which replaces a numeric value with a random number within a specified range, and partial, which…
Advertisement
AModel answer
SQL Server provides several built-in masking functions including default, which fully hides a value based on its data type, email, which partially masks an email address, random, which replaces a numeric value with a random number within a specified range, and partial, which lets you define a custom pattern showing only certain characters.
ALTER TABLE Customers
ALTER COLUMN Phone ADD MASKED WITH (FUNCTION = 'partial(0,"XXX-XXX-",4)');Real-world example
A company masks customer phone numbers so that support staff without special permission only see the last four digits, following a partial masking pattern that hides most of the number while still allowing basic identification.
Likely follow-ups
- How do you choose the right masking function for a specific type of sensitive data?
- Can you create a completely custom masking pattern beyond the built-in functions?
Related topics