How can I create custom dynamic data mask function in SQL Server?
Asked Answered
B

1

6

In SQL Server 2016 or SQL Azure, there is a feature called Dynamic Data Masking. However, it only has 4 types of masks. Is it possible to create custom mask functions? And how can I do this? I want a mask function like below(replace alphabet character with *):

String in database:

How do you do?

After masking:

*** ** *** **?
Buckeye answered 21/8, 2017 at 3:35 Comment(0)
C
0

I think you should use the Custom String function

Something like this should do the trick

Alter Table[YourSchema].[YourTableName] Alter Column YourColumn Add masked with (function='Partial(0,"*",0)')

I didn't have time to test it so is a bit of a "blind clue"

You can check this article: https://www.sqlservercentral.com/articles/dynamic-data-masking-feature-in-sql-server-2016

I think it will be useful

Carnivore answered 21/4, 2020 at 20:7 Comment(2)
This would create "*************" instead of "*** ** *** **"Ajaajaccio
@ChristopherElliott That's not right. This would actually return *. The mask value is static.Oeildeboeuf

© 2022 - 2024 — McMap. All rights reserved.