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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - 邵印中

DBF数据库资料 DELPHI高精度计时方法,取毫秒级时间精度 电脑不能开机之U盘问题 电脑自动关机之CPU风扇烧坏 广州小灵通呼叫转移 - 邵印中 - 博客园 数字电视,方便了谁 解决连接SQL Server 2000的TCP/IP错误的Bug 商品EAN13条码的生成 关于错误“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 学习资源
商品条码的生成
邵印中 · 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语句,相当方便。