|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Mask certain number of a Credit Card Number?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. something simple like this?
declare @a varchar(20) set @a = '1234-5678-9012' select stuff(@a,1,9,'XXXX-XXXX') Thank you.
-- Show quoteMarco "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/ > > > 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. -- Show quoteArnie Rowland* "To be successful, your heart must accompany your knowledge." "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 > > 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 > >
Other interesting topics
|
|||||||||||||||||||||||