• Never mind, Lynn... I see why you're subtracting from 10... I did a validation of a full number and you're calculating the check digit.

    Modification of my code will change it from validation to calculating the check digit...

    DECLARE @TestData VARCHAR(12),

    @ControlString CHAR(36)

    SELECT @TestData = '03EA12J78',

    @ControlString = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

    SELECT 10-(SUM(((N+1)%2+1)*(CHARINDEX(SUBSTRING(@TestData, N, 1),@ControlString)-1))%10)

    FROM dbo.Tally

    WHERE N <= LEN(@TestData)

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)