Below are my results when trying to mask a string column by showing only the first 5 characters.
When the string contains 5 characters, and I am masking it usingFUNCTION='partial(5,"xxxx",0)',it does not show anything. I believe it should show 5 characters plus the xxxx.
Is this a bug or am I doing something wrong?
If it is not a bug, then how do I mask the string column such that it always shows the first 5 characters?
NOTE: it would be quite a usual item to mask a zip column to hide the last 4 digits only - i.e. to show only the first 5 characters of zip.
Thank you for your help,
Janet nelson
CREATETABLE dbo.CustomerZip(
CustomerIDINTIDENTITYPRIMARYKEY,
Zip9 varchar(10),
Zip9Mask4 varchar(10)MASKEDWITH (FUNCTION='partial(4,"xxxx",0)')NULL,
Zip9Mask5 varchar(10)MASKEDWITH (FUNCTION='partial(5,"xxxx",0)')NULL
);
INSERTINTO dbo.CustomerZip(Zip9,Zip9Mask4,Zip9Mask5)
VALUES
('12345','12345','12345'),
('123456789','123456789','123456789'),
('023451234','023451234','023451234'),
('02345123','02345123','02345123'),
('0234512','0234512','0234512'),
('123451','123451','123451'),
('02345','02345','02345'),
('98765','98765','98765')
go
-- AnyUser does NOT have UNMASK privileges
GRANTSELECTON dbo.CustomerZipTO AnyUser;
GO
EXECUTEASUSER='AnyUser'
SELECT*FROM dbo.CustomerZip
GO
REVERT
GO
/*
CustomerID Zip9 Zip9Mask4 Zip9Mask5
1 12345 1234xxxxxxxx
2 123456789 1234xxxx 12345xxxx
3 023451234 0234xxxx 02345xxxx
4 02345123 0234xxxx 02345xxxx
5 0234512 0234xxxx 02345xxxx
6 123451 1234xxxx 12345xxxx
7 02345 0234xxxxxxxx
8 98765 9876xxxxxxxx
*/