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

推荐订阅源

T
Troy Hunt's Blog
F
Fortinet All Blogs
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
The Register - Security
The Register - Security
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
V
Vulnerabilities – Threatpost
S
Securelist
S
SegmentFault 最新的问题
T
Threat Research - Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Privacy International News Feed
S
Schneier on Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
GbyAI
GbyAI
Apple Machine Learning Research
Apple Machine Learning Research
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
美团技术团队
Cyberwarzone
Cyberwarzone
C
Cisco Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google Online Security Blog
Google Online Security Blog
M
MIT News - Artificial intelligence
U
Unit 42
V
V2EX
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
B
Blog
博客园 - 叶小钗
Attack and Defense Labs
Attack and Defense Labs
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - Franky
Engineering at Meta
Engineering at Meta
Schneier on Security
Schneier on Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
IT之家
IT之家
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
Martin Fowler
Martin Fowler
SecWiki News
SecWiki News

博客园 - 唐朝程序员

推荐一个winform 界面交互类库转 DBCC SHOWCONTIG、DBCC DBREINDEX。 SQL Server2005索引碎片分析和解决方法 some things 微软自带的防反编译工具dotfuscator.exe的使用 在HttpModule中使用gzip,deflate协议对aspx页面进行压缩(转) SQL查询重复数据和清除重复数据 lucene 笔记 windows系统事件查询 2010考研冲刺必备 2010公务员考试必备资料 url重写适用html为伪静态后真实的html无法访问的解决方法 SQL的 优化 (某篇的精简版) SQL 优化 (某篇的精简版) U影资源网原域名被封了,现在叫狐库网,启用了新的域名 vs2008 下载地址以及正式版序列号 Windows XP和Office2003通过正版验证,免去黑屏之忧 NOKIA诺基亚PC套件在2003系统上的安装方法 在.net 2.0 中使用ftp
SqlServer的汉字转拼音码的函数
唐朝程序员 · 2010-01-27 · via 博客园 - 唐朝程序员

代码

--
--
 Definition for user-defined function f_GetPy : 
--
GO
create   function   [dbo].f_GetPy(@str   nvarchar(4000)) 
returns   nvarchar(4000
as 
begin 
declare   @strlen   int,@re   nvarchar(4000
declare   @t   table(chr   nchar(1)   collate   Chinese_PRC_CI_AS,letter   nchar(1)) 
insert   into   @t(chr,letter) 
    
select   '吖 '''   union   all   select   '八 '''   union   all 
    
select   '嚓 '''   union   all   select   '咑 '''   union   all 
    
select   '妸 '''   union   all   select   '发 '''   union   all 
    
select   '旮 '''   union   all   select   '铪 '''   union   all 
    
select   '丌 '''   union   all   select   '咔 '''   union   all 
    
select   '垃 '''   union   all   select   '嘸 '''   union   all 
    
select   '拏 '''   union   all   select   '噢 '''   union   all 
    
select   '妑 '''   union   all   select   '七 '''   union   all 
    
select   '呥 '''   union   all   select   '仨 '''   union   all 
    
select   '他 '''   union   all   select   '屲 '''   union   all 
    
select   '夕 '''   union   all   select   '丫 '''   union   all 
    
select   '帀 ''' 
    
select   @strlen=len(@str),@re= ' ' 
    
while   @strlen> 0 
    
begin 
        
select   top   1   @re=letter+@re,@strlen=@strlen-1 
            
from   @t   a   where   chr <=substring(@str,@strlen,1
            
order   by   chr   desc 
        
if   @@rowcount=0 
            
select   @re=substring(@str,@strlen,1)+@re,@strlen=@strlen-1 
    
end 
    
return(@re
end

代码

//用法一
string sql = string.Format("Name like '%{0}%' or dbo.f_GetPy(Name) like '{0}%' ", goodsName);//用法二
string sql = string.Format(@"Select * from (Select Company_Name from tb_enterprise where Company_Name like '%{1}%' or F_PINYIN(Company_Name) like '%{1}%' ) 
                                         WHERE ROWNUM <= {0} ORDER BY ROWNUM ASC
", topCount, name);