I have a 15 digit customer number that I need to calculate a check digit for that value.
In order to come up with the check digit I use Excel (formula is below).
This formula is based on something called the Luhn Algorithm (I think that is the correct spelling).
The 15 digit customer number is stored in a SQL Server 2000 database.
I would like to be able to get this calculation using a T-SQL function rather than Excel. Does anyone know how this can be done with T-SQL on a SQL Server 2000 database?
Excel formula that will give me a check digit from a 15 digit number is this:
=MOD(SUMPRODUCT(-MID(TEXT(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)*(MOD(ROW(INDIRECT("1:"&LEN(A2)))+LEN(A2)+1,2)+1),"00"),{1,2},1)),10)
1 Answer