Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
getur.srikanth@gmail.com
Yak Posting Veteran
77 Posts |
Posted - 2007-12-20 : 11:29:44
|
| I need to mask credit card to maskedcreditcard. last 4 digits should display and remaining should mask with "*".Ex: 4443335556661111 to ************1111Thanks in advance |
|
|
pootle_flump
1064 Posts |
Posted - 2007-12-20 : 11:32:08
|
| [code]DECLARE @no AS VARCHAR(16)SELECT @no = '4443335556661111'SELECT @no = REPLICATE('*', DATALENGTH(@no) - 4) + RIGHT(@no, 4)SELECT @no[/code] |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2007-12-20 : 12:09:38
|
A credcard number has a fixed lengt so this would probably be easier:SELECT '**** **** **** ' + RIGHT(@no, 4) --Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand" |
 |
|
|
timark
Starting Member
11 Posts |
Posted - 2007-12-23 : 12:52:45
|
| Yup, in fact, the receipts I've been getting lately just use a single asterisk in front of the last for digits, as so: VISA *1234All you'd have to do is draw the card type and the last four digits of the number as a string.SELECT CardType + " " + right(CardNumber, 4) AS ReceiptCardNumber |
 |
|
|
|
|
|