Mask Credit Card Number

Posted: October 7, 2010 in SQL Server 2005

When trying to mask a credit card value so that only the last 4 digits are visible in the format XXXXXXXXXXXXNNNN, you can try the following:

-- Declare variables
DECLARE @lv_credit_card_no VARCHAR(20);

-- Intialise variables
SET @lv_credit_card_no = '1234567890123456';

-- Mask credit card value
SELECT STUFF(@lv_credit_card_no, 1, 12, 'XXXXXXXXXXXX');
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s