Here is how you get the check digit for UPC-12.CREATE FUNCTION dbo.fnGetUPC( @UPC VARCHAR(11))RETURNS VARCHAR(12)ASBEGIN DECLARE @Index TINYINT, @Multiplier TINYINT, @Sum TINYINT SELECT @Index = LEN(@UPC), @Multiplier = 3, @Sum = 0 WHILE @Index > 0 SELECT @Sum = @Sum + @Multiplier * CAST(SUBSTRING(@UPC, @Index, 1) AS TINYINT), @Multiplier = 4 - @Multiplier, @Index = @Index - 1 RETURN CASE @Sum % 10 WHEN 0 THEN @UPC + '0' ELSE @UPC + CAST(10 - @Sum % 10 AS CHAR(1)) ENDEND
E 12°55'05.25"N 56°04'39.16"