Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

How to calculate the check digit for a UCC/EAN code

By Sergio Govoni,

The standard coding of UCC/EAN requires that each code generated ends with a check digit between zero and nine (0 - 9).

The check digit is calculated in according to the other digits that make up the code and its purpose is to ensure that the bar code is interpreted correctly by the optical scanner.

Example:

Calculate the check digit for the UCC/EAN code equal to "0800123456789"

DECLARE @RES INT

EXEC @RES = UDF_GetCheckDigitUCCEAN '0800123456789'
PRINT (@RES)

The result is: 7.

The UCC/EAN code with check digit is: '08001234567897'.

SQL Script compatible with Microsoft SQL Server 2000.

Total article views: 1772 | Views in the last 30 days: 8
 
Related Articles
FORUM

mod 10 weights 1, 2

check digit calcualtion

FORUM

Add Check Digit (LUHN)

Comments posted to this topic are about the item [B]Add Check Digit (LUHN)[/B]

SCRIPT

Add Check Digit (LUHN)

If you ever need to create a credit card like number this stored procedure is for you. Most credi...

ARTICLE

Digital Storage

Digital technologies have made the transfer of information easier than ever, but what about it's lon...

FORUM

Check Digit calc

Hi all i'm looking for a script (udf) to calculate check digits, this is for standard food product u...

Tags
barcode    
scalar-valued functions    
t-sql    
ucc/ean    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones