
PUZZLE 60 BARCODES 237
PUZZLE
60 BARCODES
In a recent posting on www.swug.org, a regular contributor posted a
T-SQL function that calculates the checksum digit of a standard, 13-
digit barcode. The algorithm is a simple weighted sum method (see
Data & Databases, Section 15.3.1, if you do not know what that
means). Given a string of 13 digits, you take the first 12 digits of the
string of the barcode, use a formula on them, and see if the result is
the 13th digit. The rules are simple:
1. Sum each digit in an odd position to get S1.
2. Sum each digit in an odd position to get S2.
Subtract S2 from S1, do a modulo 10 on the sum, and then compute
the absolute ...