Dynamic data masking in Fabric

By Hatnest · Reviewed by Saurav Raj Joshi · Updated Nov 30, 2026

Dynamic data masking (DDM) changes what a query returns, not what is stored. You attach a mask to a column, and users who are not privileged see an obscured value, such as XXXX or a partly hidden phone number, while the stored data stays intact. Applications keep working without modification, because only the result set is altered. It applies to a warehouse and to the SQL analytics endpoint.

What it is for, and what it is not

DDM is a convenience layer for limiting accidental exposure: a support analyst running a customer query does not casually see full card numbers. It is not a hard barrier. A user who can run arbitrary queries can still probe masked columns. A range filter such as asking for rows where a salary lies between two close numbers will return matching rows even though the displayed value is masked, which reveals the real value. For true protection, combine DDM with column-level security, row-level security and tight permissions.

The four mask functions

  • default() masks completely according to the data type. Strings show XXXX (or fewer characters for short fields), numbers show zero, date and time types show 1900-01-01 00:00:00.0000000, and binary types show a single zero byte.
  • email() shows the first letter and a constant suffix in the shape aXXX@XXXX.com.
  • random(start, end) replaces a numeric value with a random one inside the range you give.
  • partial(prefix, padding, suffix) exposes the first and last characters and puts your padding string between. If the value is too short, part of the prefix or suffix is not shown.

Defining a mask

You add masks in the table definition or on an existing column.

CREATE TABLE dbo.EmployeeData (
    EmployeeID INT,
    FirstName  VARCHAR(50) MASKED WITH (FUNCTION = 'partial(1,"-",2)') NULL,
    LastName   VARCHAR(50) MASKED WITH (FUNCTION = 'default()') NULL,
    SSN        CHAR(11)    MASKED WITH (FUNCTION = 'partial(0,"XXX-XX-",4)') NULL,
    Email      VARCHAR(256) NULL
);

ALTER TABLE dbo.EmployeeData
ALTER COLUMN Email ADD MASKED WITH (FUNCTION = 'email()');

Because the ALTER COLUMN form exists, you can add a mask to an existing column, which is the way to mask a table in a SQL analytics endpoint where you cannot create tables.

Who sees masked data

Members of the workspace Admin, Member or Contributor roles, and users with elevated permissions on the warehouse, see real values, because those roles have CONTROL on the database by design. Everyone else, including Viewers, sees masked values. To let a specific user see real data, grant UNMASK, and revoke it when no longer needed.

GRANT UNMASK ON dbo.EmployeeData TO [analyst@contoso.com];
REVOKE UNMASK ON dbo.EmployeeData FROM [analyst@contoso.com];

Permissions per operation:

  • Create a table with masked columns: CREATE TABLE and ALTER on the schema.
  • Add, replace or remove a mask: ALTER ANY MASK and ALTER on the table. A good fit for a security officer.
  • See masked data: SELECT on the table.
  • See unmasked data: UNMASK on the column, or CONTROL on the database.

Choosing between DDM and its neighbors

  • Users may see the row but not the true value of a field: DDM.
  • Users must not see a column at all (the query should fail): column-level security.
  • Users must not see some rows: row-level security.
  • Users must see no sign of a table in a semantic model: object-level security.

Common mistakes

  • Treating a mask as encryption or as the only protection.
  • Testing the mask while signed in as an admin or Contributor, who never sees it. Test with an account that has no elevated rights.
  • Applying partial() with the wrong order of arguments (prefix, padding, suffix).
  • Granting UNMASK broadly for convenience.

For the exam

  • Four functions: default, email, random, partial (custom string).
  • Masking changes query results only; stored data is unchanged.
  • Admin, Member and Contributor, and anyone with CONTROL, see unmasked data; others need UNMASK.
  • ALTER ANY MASK manages masks; it is not a substitute for column-level or row-level security.
  • Masks can be added to existing columns with ALTER COLUMN.

Sources