Home All Groups Group Topic Archive Search About

Mask certain number of a Credit Card Number?

Author
14 Jul 2006 5:20 AM
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

Author
14 Jul 2006 5:35 AM
Omnibuzz
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/
Author
14 Jul 2006 5:54 AM
Marco Napoli
Thank you.

--
Marco

Show quote
"Omnibuzz" <Omnib***@discussions.microsoft.com> wrote in message
news:099C4B03-1483-4A8C-95A7-E4BD518E6754@microsoft.com...
> 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/
>
>
>
Author
14 Jul 2006 6:05 AM
Arnie Rowland
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."



Show quote
"Marco Napoli" <marco@avantitecnospam.com> wrote in message
news:e8PkAVwpGHA.5104@TK2MSFTNGP04.phx.gbl...
>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
>
>
Author
14 Jul 2006 6:28 AM
Uri Dimant
Marko
There are a few STRING function in the SQL Server like STUFF,SUBSTRING  to
do it for you



Show quote
"Marco Napoli" <marco@avantitecnospam.com> wrote in message
news:e8PkAVwpGHA.5104@TK2MSFTNGP04.phx.gbl...
>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
>
>

AddThis Social Bookmark Button