Reputation: 19
I want to give database access to someone else, but I want to hide sensitive data like credit card numbers and email addresses. The Masked function does not work in SQL server 2012.
What is the best way of solving this problem?
Upvotes: 1
Views: 3731
Reputation: 43666
You are not able to use new stuff like dynamic data masking or row level security to restrict access to certain fields or rows, so you can go to the old way.
Create views and expose only the fields you need to show. Grant access to these views only.
Don't be sad about the dynamic data masking. It is not a security feature and there various techniques to expose the information.
Try something like this:
CREATE VIEW [dbo].[vw_SenstiveData]
AS
SELECT [UserID]
,'XXXXXXXX' AS [UserName]
,LEFT([SocialID], 4) + '-XXX-XXX-XXXXXXX-' + RIGHT([SocialID], 3) AS [SocialID]
FROM [dbo].[Users]
Upvotes: 1