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

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - 邵印中

DBF数据库资料 DELPHI高精度计时方法,取毫秒级时间精度 电脑不能开机之U盘问题 电脑自动关机之CPU风扇烧坏 广州小灵通呼叫转移 - 邵印中 - 博客园 数字电视,方便了谁 解决连接SQL Server 2000的TCP/IP错误的Bug 商品条码的生成 关于错误“Cannot connect to the Citrix MetaFrame server.Can't assign requested address”的解决方法 电脑死机之CPU温度过高 winrar 8 注册方法 "加载类型库/dll时出错" 的解决方法 删除子窗体中的控件中的某些属性时出现"Selection contains a component introduced in an ancestor form which cannot be deleted."错误的解决方法 SC命令配置服务 SQL 2005如何更改服务器身份验证模式 There is no Citrix MetaFrame server configured on the specified address错误的解决方法 ASP.NET AJAX,WCF,ADO.NET Entity 开发实例 Citrix 客户端登录出现wfshell.exe - 应用程序错误的解决方法 WCF 学习资源
商品EAN13条码的生成
邵印中 · 2009-07-26 · via 博客园 - 邵印中

最近客户要求在货品资料中生成商品条码(即EAN13,国际商品条码),虽然系统中有商品条码生成的工具,但是对不上号,根本无法使用,客户的货品资料已经有部分有条码,更重要的是客户要求生成商品条码的货品无法正常筛选出来(比如:GW开头,或者是GM开头,而且要求的是GW和GM后面全是数字的货品才要求生成),客户又急着用,没有办法的情况下,就自己动手写了一个小工具,虽然客户无法使用,但是对于维护客户的商品条码生成,确是相当的方便,现记录下,以便将来查看:
生成EAN13条码的SQL函数代码:
create function dbo.EAN13(@value varchar(13))
    returns varchar(13)
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 13 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),12)+ltrim(10-case @s3 when '0' then '10' else @s3 end)
end
go
函数调用:
select dbo.ean13(694386035966) 返回值:6943860359663
在程序中执行时,可以手工写入SQL语句,这样,可以自由的提出要生成的货品资料,例如:
select code,name,standardcode from goods where (patindex('GW[0-9]%',Code)>0 or patindex('GM[0-9]%',Code)>0) and
(standardcode is  null)
动态的指定SQL语句,相当方便。