ajay raju

ajay raju

  • NA
  • 398
  • 0

how to find out last four characters using substring?

Aug 11 2010 11:59 PM

Hi sir,
  i am displaying credit card number in Textbox. my aim display only last four numbers reamaing are display in 'X' symbol.
  
 i am write substring like
SELECT  + 'XXXXXXXXXXXX'+ SUBSTRING(CardNumber,13,LEN(CardNumber)) AS CardNumber FROM tbl_CreditcardInfo WHERE ID = @ID

my problem is if card number is 16 digits its work fine, but if cardNO is 15 or 14 digits that time it display only last 3 or 2 numbers
but my aim is if user enter 14 or 15 or 16 any digts it display only last 4 characters. and remaing first characters displayed 'X' mark.
Please give a solution, and where i modify my query.
Thanks.

Answers (3)