惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
A
About on SuperTechFans
量子位
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
Google DeepMind News
Google DeepMind News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
G
Google Developers Blog
U
Unit 42
D
DataBreaches.Net
博客园 - Franky
D
Docker
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hugging Face - Blog
Hugging Face - Blog

博客园 - 禹过天晴

TextControl技术互助 博文阅读密码验证 - 博客园 (转)不通过web.config在运行时注册httpmodules (学)如何在Oracle中一次执行多条sql语句 (学)条件性唯一性索引的建议 阿里云服务器IIS启用HTTPS协议(转) (学)递归查找窗体中全部控件 (原)用WebBrowser浏览Office Web Apps Server,除去“下载”按钮 博文阅读密码验证 - 博客园 如何让Oracle表及字段显示为区分大小写(转) (转)SQL Server 列转行 博文阅读密码验证 - 博客园 博文阅读密码验证 - 博客园 (原)将Oracle迁移到SQLServer (转)Sql Server 快速查看表结构(表描述及字段说明) 博文阅读密码验证 - 博客园 (转)SQL查询案例:多行转换为一行 (转)找回vss超级管理员密码 (转)SqlServer里DateTime转字符串
(转)基于SQL的EAN13、ENA8条形码校验位生成
禹过天晴 · 2017-07-03 · via 博客园 - 禹过天晴

USE [DB]
GO
/****** Object: UserDefinedFunction [dbo].[EAN13] Script Date: 07/04/2017 15:21:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/**
--功能:获取EAN-13码的检验位
--Author:josy(百年树人)
--参数@s:EAN-13码前12位
**/
ALTER function [dbo].[EAN13](@s char(12))
returns varchar(1)
as
begin
return (10-(
(cast(substring(@s,2,1) as int)+substring(@s,4,1)+substring(@s,6,1)
+substring(@s,8,1)+substring(@s,10,1)+substring(@s,12,1)
)*3
+substring(@s,1,1)+substring(@s,3,1)+substring(@s,5,1)
+substring(@s,7,1)+substring(@s,9,1)+substring(@s,11,1)
)%10)%10
end

create function dbo.EAN8 (@value varchar(8))
returns varchar(8)
as
begin
declare @s1 int ,@s2 int,@s3 int
declare @t table (id int identity(1,1),b bit)
insert into @t(b)
select top 8 1 from syscolumns
set @value='0'+reverse(@value)
select @s1=sum(cast(substring(@value,id,1) as int))
from @t a
where len(@value)>=id and id%2=0
set @s1=@s1*3
select @s2=sum(cast(substring(@value,id,1) as int))
from @t a
where len(@value)>=id and id>=3 and id%2=1
set @s3=right(@s1+@s2,1)
return left(reverse(@value),7)+ltrim(10-case @s3 when '0' then '10' else @s3 end)
end
go