April 21, 2004 at 11:11 am
Is there any way I can calculate a checksum digit using 'Sum of Product - Mod 10' method without looping through each digit?
What I mean by 'Sum of Product - Mod 10' is:
- Multiply each digit with 1 or 2 and sum the result of all such calculations on each digit
- Check sum digit is = 10 - (Sum % 10)
Example string : 02530010828400000008607
Thanks.
April 21, 2004 at 4:34 pm
Not sure if it uses the 'Sum of Product - Mod 10' method you were talking about but...
Have you tried the CHECKSUM function in SQL? It's in "Books on line".
--Jeff Moden
--Jeff Moden
Change is inevitable... Change for the better is not.
April 22, 2004 at 9:13 am
CHECKSUM routine is used to get a unique (in almost all cases but no guarantees) numeric value for a column value so that this unique value can be used to create performance enhancing indices. I can't find the underlying implementation of the routine but it does not return a check digit.
I have created a stored proc that returns my check digit value on any string using the Mod-10 Sum of Product method. It serves my purpose. I was looking for something similar to CHECKSUM that I can apply to the string directly rather than looping through each digit in the string. Anyway, thanks.
May 4, 2004 at 1:08 pm
Farhan,
Would you be willing to shared code of your stored procedure... We have a need for same.
May 4, 2004 at 1:40 pm
If you want to get a checksum against the full table you can do something like the following...
SELECT CHECKSUM_AGG(BINARY_CHECKSUM(*))
FROM Foo WITH(NOLOCK)
Gary Johnson
Microsoft Natural Language Group
DBA, Sr. DB Engineer
This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.
May 4, 2004 at 2:13 pm
Hrm. the _agg version is not something I was familiar with. Thanks
/hijack off
July 7, 2004 at 8:25 am
Can anyone give me the code for a stored procedure in order to check the validity of a code using the Check Digit Algorithm (Modulus 10).
July 8, 2004 at 3:13 pm
I have a function that does it all for you. Inparameters are data and boolean wether or not checkdigit is included.
Return value is either checkdigit or true/false if checkdigit was included
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply