如何使用 SQL Server 2016 Dynamic Data Masking 忽略空字符串?

How to ignore empty strings with SQL Server 2016 Dynamic Data Masking?

我正在实施 SQL Server 2016 Data Masking 作为一项测试,作为为应用程序提供 'demo' 模式的总体工作的一部分,该模式在展示时不会公开真实数据。

我们有一个遵循模式 0411 222 333(澳大利亚手机号码)的手机号码字段,下面的部分掩码正确应用了我们之后的标准掩码,就是说 04XX XXX X33

ALTER TABLE Resource
ALTER COLUMN MobileNumber ADD MASKED WITH (FUNCTION='partial(2, "XX-XXX-X",2)')

但是,如果列的值为空字符串 (''),则仍会应用掩码,尽管没有要掩码的数据:

有没有办法确保屏蔽工作忽略空字符串?

有关此功能的 MSDN 文章还有很多不足之处。但我确实找到了另一篇与 Azure 有关的类似文章,似乎可以回答您的问题。

Custom text:

Masking method which exposes the first and last characters and adds a custom padding string in the middle. If the original string is shorter than the exposed prefix and suffix, only the padding string will be used. prefix[padding]suffix

https://azure.microsoft.com/en-us/documentation/articles/sql-database-dynamic-data-masking-get-started/