No, if you only want masking for certain rows, you cannot do that with Dynamic Data Masking. DDM will mask all values in a column.
Dynamic Data masking at Row level
Currently we have a static Data masking implemented based a case statement like below:- Create View "view_name" AS Select Column1, Case when (column10 = 1) then column 2 else 'XXXX' end as column2, column3, column4 From "Table_name" **As you can see above for column 2 we have applied Masking based on a value in a column10 at view level. ----Now we want to explore if the same case statement can be applied for DYNAMIC DATA MASKING---- Please advice.
SQL Server Other
2 answers
Sort by: Most helpful
-
Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
2023-04-04T22:08:50.0533333+00:00 -
Anonymous
2023-04-06T07:51:23.09+00:00 Hi @Vinay Reddy There is this line in the official document you posted, which indicates that DDM acts on the column. It doesn't seem to work with the case statement, and your idea doesn't seem to be realizable.
I also checked out a nice post with a detailed explanation of DDM usage. https://www.red-gate.com/simple-talk/databases/sql-server/t-sql-programming-sql-server/encrypting-sql-server-dynamic-data-masking/