Dynamic Data Masking Issue when Concatenating Fields
Documentation is shamefully silent in regard to what is the behavior when masked column is the part of an expression.
This is how masked column is represented in execution plan:
Scalar Operator(DataMask([LastName],0x05000000,(3),(2),'XXXX',(2)))

here (3) denotes masking function type and correspond to partial masking.
And this is how LastName + ', ' + FirstName expression is represented:
Scalar Operator(DataMask([LastName]+', '+[FirstName],0x05000000,(1),(0),(0),(0)))

As you may see, the behavior is &quot;compute, then mask&quot;. Masking function type in this case is (1), which correspond to default masking. This is the result of masking function adjustment and intentional modification.
With the &quot;compute, then mask&quot; approach, this (mask adjustment) is the necessary measure apparently, because of otherwise simple expressions involving LEFT, RIGHT or SUBSTRING functions could unmask data easily. And determining whether expression is &quot;safe&quot; or not would be too complex probably.
I can only guess why approach is &quot;compute, then mask&quot; and not &quot;mask, then compute&quot;, but I think that the latter, being implemented, would suffer from its own problems. Some, that I can think of, include possibility of arithmetic errors for numeric types (such as division by zero, for example, if something is divided to masked column), or logic skew possibility (if there is a conditional expression that depends on masked column).