Click here to Skip to main content
Click here to Skip to main content

Selective masking in SQL server 2005

By , 5 Jan 2012
 
--Mask all but show only last 3 digits of the phone number
DECLARE @PhoneNo varchar(10), @Mask varchar(10)
SELECT @PhoneNo = '1234567890', @Mask = 'XXXXXXXXXX' 
 
SELECT @PhoneNo as 'Phone No', replace(@PhoneNo, substring(@PhoneNo, 1, len(@PhoneNo) - 3), 
substring(@Mask, 1, len(@PhoneNo) - 3)) as 'MaskedPhoneNumber'

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Jobless Creature
Software Developer (Senior)
India India
Member
I have a total experience of around 5 years out of which 4 years in MS technologies. I have a passion towards coding.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 5 Jan 2012
Article Copyright 2012 by Jobless Creature
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid