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

推荐订阅源

V
Vulnerabilities – Threatpost
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
P
Palo Alto Networks Blog
大猫的无限游戏
大猫的无限游戏
量子位
S
Secure Thoughts
博客园 - 【当耐特】
V
Visual Studio Blog
腾讯CDC
爱范儿
爱范儿
Webroot Blog
Webroot Blog
The Register - Security
The Register - Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Latest news
Latest news
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Cloudbric
Cloudbric
T
Troy Hunt's Blog
S
Security @ Cisco Blogs
B
Blog RSS Feed
I
Intezer
S
SegmentFault 最新的问题
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
C
CXSECURITY Database RSS Feed - CXSecurity.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
TaoSecurity Blog
TaoSecurity Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recorded Future
Recorded Future
Google DeepMind News
Google DeepMind News
Forbes - Security
Forbes - Security
雷峰网
雷峰网
博客园 - 司徒正美
C
Cisco Blogs
S
Securelist
L
LINUX DO - 最新话题
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
N
News | PayPal Newsroom
N
News and Events Feed by Topic

博客园 - kwame

CXX0017错误的解决办法 基础知识--is & as 的区别 - kwame 基础知识--变量和常量 - kwame - 博客园 基础知识--Boxing & unBoxing 基础知识--值类型和引用类型 用Visual C#创建Windows服务程序 (转)用C语言编写Windows服务程序的五个步骤 昨天的事今天来写也叫昨天的日记吧?? 我是个被窥视狂? 一个馒头和一个*六*合*彩*网站引发的血案 *六*合*彩*网站也能做成这样不容易呀! 写入、读取 cookie 无聊顺便复习了下前面学的东西! 网页效果集合(小技巧) Oracle中隐式游标和显式游标的教训[同事的经历] C#.net word 受控编程系列1-向word中插入图片 安装和部署企业程序库(Installation and Deployment of Enterprise Library) OA需要分析3 OA需求分析2 OA需求分析1
取得一段汉语的每个字的首字母
kwame · 2006-03-03 · via 博客园 - kwame

由于一个公司的OA上用到速查编码,必须得到每个字的首字母,便于以后的查询(如:开发部,则为KFB),到网上找到了一些资料,是一个存储过程。

存储过程为:
CREATE  proc LOG_FindCode
@strName nvarchar(20),
@strFindCode nvarchar(20) output
as
begin
declare @word nchar(1),@PY nvarchar(4000)
set @PY=''
while len(@strName)>0
begin
set @word=left(@strName,1)
set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
then (select top 1 PY from (
select 'A' as PY,N'驁' as word
union all select 'B',N'簿'
union all select 'C',N'錯'
union all select 'D',N'鵽'
union all select 'E',N'樲'
union all select 'F',N'鰒'
union all select 'G',N'腂'
union all select 'H',N'夻'
union all select 'J',N'攈'
union all select 'K',N'穒'
union all select 'L',N'鱳'
union all select 'M',N'旀'
union all select 'N',N'桛'
union all select 'O',N'漚'
union all select 'P',N'曝'
union all select 'Q',N'囕'
union all select 'R',N'鶸'
union all select 'S',N'蜶'
union all select 'T',N'籜'
union all select 'W',N'鶩'
union all select 'X',N'鑂'
union all select 'Y',N'韻'
union all select 'Z',N'咗'
) T
where word>=@word collate Chinese_PRC_CS_AS_KS_WS
order by PY ASC) else @word end)
set @strName=right(@strName,len(@strName)-1)
end
set @strFindCode=@PY
end

下面是把汉语传入,调用存储过程得到速查编码的方法

public string GetPY(string Name)//得到速查编码
 {
  SqlCommand cmd=new SqlCommand();
  cmd.CommandType=CommandType.StoredProcedure;//类型为存储过程
  cmd.CommandText="LOG_FindCode";//已经创建好的存储过程名
  cmd.Connection=con;
  con.Open();
  SqlParameter parName=new SqlParameter();
  parName.ParameterName="@strName";
  parName.SqlDbType=SqlDbType.NVarChar;
  parName.Size=20;
  parName.Value=Name;

  SqlParameter parMsg=new SqlParameter();
  parMsg.ParameterName="@strFindCode";
  parMsg.Direction=ParameterDirection.Output;
  parMsg.SqlDbType=SqlDbType.NVarChar;
  parMsg.Size=50;
  cmd.Parameters.Add(parName);
  cmd.Parameters.Add(parMsg);

  cmd.ExecuteReader();
  string strFindCode=parMsg.Value.ToString();
  con.Close();
  return strFindCode;
 }

转自:http://sqlserver.bokewu.com/blog50135.htm