Validating sin numbers
Here's how the algorithm works for verifying credit cards; the math is quite simple: 1) Starting with the second to last digit and moving left, double the value of all the alternating digits.
2) Starting from the left, take all the unaffected digits and add them to the results of all the individual digits from step 1.
To generate the check digit, the LUHN formula is applied to the number.
Based on ANSI X4.13, the LUHN formula (also known as the modulus 10, or mod 10, algorithm) is used to generate and/or validate and verify the accuracy of credit-card numbers.
And if you're storing more than numeric data (e.g.
the delimiters), then wouldn't you need more than 15 characters to store a formatted 15-digit number?
As of now, we are expecting phone numbers to come in a number of formats (from an XML file). If 2 or 3 are yes, I think I'd do two fields and some kind of crazy parser to determine what is extension or other data and deal with it appropriately.
This field needs to be indexed heavily as Sales Reps can use this field for searching (including wild character search). If the first is a yes and the other two are no, I'd use two varchar(50) fields, one for the original input and one with all non-numeric data striped and used for indexing.