Dynamic Data masking at Row level

Vinay Reddy 0 Reputation points
2023-04-04T07:37:36.7333333+00:00

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
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-04-04T22:08:50.0533333+00:00

    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.


  2. 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. User's image

    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/


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.