This UDF will validate a credit card number using Luhn's formula.For example 49927398716 will return 1:
print dbo.luhn('49927398716')
print dbo.luhn(49927398716)
1
1
based on:
Credit cards, validation and the Luhn formula
by
Eduardo Chaves
http://www.webdevelopersjournal.com/articles/validation.html
Algorithm converted to TSQL by Joseph Gama
2007-10-02 (first published: 2002-06-20)
15,451 reads