Discussion:
Mask certain number of a Credit Card Number?
(too old to reply)
Marco Napoli
2006-07-14 05:20:40 UTC
Permalink
I have a VarChar field that stores Credit Card numbers, is there a way in a
SELECT statement to mask certain portions of the Credit Card Number?

For example: 1234-5678-9012 would show as xxxx-xxxx-9012

Thank you.
--
Peace in Christ
Marco Napoli
http://www.ourlovingmother.org
Omnibuzz
2006-07-14 05:35:01 UTC
Permalink
something simple like this?

declare @a varchar(20)
set @a = '1234-5678-9012'

select stuff(@a,1,9,'XXXX-XXXX')
--
-Omnibuzz (The SQL GC)

http://omnibuzz-sql.blogspot.com/
Marco Napoli
2006-07-14 05:54:06 UTC
Permalink
Thank you.
--
Marco
Post by Omnibuzz
something simple like this?
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/
Arnie Rowland
2006-07-14 06:05:25 UTC
Permalink
The primary question, sincerely asked, is why are you taking the risk of
storing credit card numbers?

You could use the right() function and take only the last four numbers to
store -why store the 'xxxx-xxxx' part?.

But it seems that you really asking about a display mask. If you are
concerned about masking the data in a SELECT statement, then shouldn't you
really be asking if it is appropraite to be storing the data at all?

If you are using the last four digits for account verification, you could
store the last four digits in a one way hash and do a compare.
--
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
Post by Marco Napoli
I have a VarChar field that stores Credit Card numbers, is there a way in a
SELECT statement to mask certain portions of the Credit Card Number?
For example: 1234-5678-9012 would show as xxxx-xxxx-9012
Thank you.
--
Peace in Christ
Marco Napoli
http://www.ourlovingmother.org
Uri Dimant
2006-07-14 06:28:02 UTC
Permalink
Marko
There are a few STRING function in the SQL Server like STUFF,SUBSTRING to
do it for you
Post by Marco Napoli
I have a VarChar field that stores Credit Card numbers, is there a way in a
SELECT statement to mask certain portions of the Credit Card Number?
For example: 1234-5678-9012 would show as xxxx-xxxx-9012
Thank you.
--
Peace in Christ
Marco Napoli
http://www.ourlovingmother.org
Loading...