Click here to Skip to main content
12,697,311 members (28,344 online)
Click here to Skip to main content
Add your own
alternative version


1 bookmarked

Selective masking in SQL server 2005

, 5 Jan 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Masking selected characters in SQL, hiding few characters
--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'


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) TATA Communications
India India
I have a total experience of around 5 years out of which 4 years in MS technologies. I have a passion towards coding.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 5 Jan 2012
Article Copyright 2012 by Jobless Creature
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid