Click here to Skip to main content
15,893,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to unmask a credit card number in sql server 2008. Here card number is being masked and its length fixed.

For instance: Card nO: 5338190112341234

Masked as XXXXXX01XX1234

I want to generate the exact unmasked value of (XXXXXX01XX1234) and also check whether its unique using sql function.
Posted
Comments
Ankur\m/ 22-Oct-13 2:49am    
How are you masking it? Are you actually replacing the numbers with X's while saving or you just mask them while displaying? Also do you have some kind of encryption in place while saving the CC numbers?
[no name] 22-Oct-13 4:33am    
DECLARE @MaskedCardNo VARCHAR(1000)
set @MaskedCardNo=''

SELECT @MaskedCardNo = 'XXXXXX' + SUBSTRING(@CardNo,7,2) +'XXXX' + SUBSTRING(@CardNo,13,4)
IF(@MaskedCardNo='XXXXXXXXXX')--CardNo is NULL means(maskedno=XXXXXXXXXX) then Set Masked card No as empty string
SET @MaskedCardNo=''
RETURN @MaskedCardNo
We are using SCALAR VALUED FUNCTION and calling it for displaying. But in one case from excel we are taking masked card and has to insert or update unmasking in db. Any sql fn or way to generate the exact unique card no: Its length is 16 digit and fixed

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900