/*-1.-获得汉字字符串的首字母

   根据大力的贴子改成.将大力的两个函数合并成了一个函数.
   可以应用于助记码的查询
--转载(最早见于j9988的发表,具体原作者不明)--*/

[转]汉字转拼音的存储过程if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fGetPy]'and xtype in (N'FN', N'IF', N'TF'))
[转]汉字转拼音的存储过程
drop function [dbo].[fGetPy]
[转]汉字转拼音的存储过程
GO
[转]汉字转拼音的存储过程
[转]汉字转拼音的存储过程
--创建取拼音函数
[转]汉字转拼音的存储过程
create function fGetPy(@Str varchar(500)='')
[转]汉字转拼音的存储过程
returns varchar(500)
[转]汉字转拼音的存储过程
as
[转]汉字转拼音的存储过程
begin
[转]汉字转拼音的存储过程 
declare @strlen int,@return varchar(500),@ii int
[转]汉字转拼音的存储过程 
declare @n int,@c char(1),@chn nchar(1)
[转]汉字转拼音的存储过程
[转]汉字转拼音的存储过程 
select @strlen=len(@str),@return='',@ii=0
[转]汉字转拼音的存储过程 
set @ii=0
[转]汉字转拼音的存储过程 
while @ii<@strlen
[转]汉字转拼音的存储过程 
begin
[转]汉字转拼音的存储过程  
select @ii=@ii+1,@n=63,@chn=substring(@str,@ii,1)
[转]汉字转拼音的存储过程  
if @chn>'z'
[转]汉字转拼音的存储过程  
select @n = @n +1
[转]汉字转拼音的存储过程     ,
@c = case chn when @chn then char(@nelse @c end
[转]汉字转拼音的存储过程   
from(
[转]汉字转拼音的存储过程    
select top 27 * from (
[转]汉字转拼音的存储过程     
select chn = ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select ''  --because have no 'i'
[转]汉字转拼音的存储过程
     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 ''  --no 'u'
[转]汉字转拼音的存储过程
     union all select ''  --no 'v'
[转]汉字转拼音的存储过程
     union all select ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select ''
[转]汉字转拼音的存储过程     
union all select @chnas a
[转]汉字转拼音的存储过程    
order by chn COLLATE Chinese_PRC_CI_AS 
[转]汉字转拼音的存储过程   ) 
as b
[转]汉字转拼音的存储过程  
else set @c='a'
[转]汉字转拼音的存储过程  
set @return=@return+@c
[转]汉字转拼音的存储过程 
end
[转]汉字转拼音的存储过程 
return(@return)
[转]汉字转拼音的存储过程
end
[转]汉字转拼音的存储过程
[转]汉字转拼音的存储过程
go
[转]汉字转拼音的存储过程
--测试
[转]汉字转拼音的存储过程
select dbo.fgetpy('东莞市'as 东莞市,dbo.fgetpy('ab中c国人'as 中国人
[转]汉字转拼音的存储过程
[转]汉字转拼音的存储过程
--删除拼音函数
[转]汉字转拼音的存储过程
drop function fgetpy
[转]汉字转拼音的存储过程
[转]汉字转拼音的存储过程

 

 

/*2.--获得汉字拼音的函数

  需要创建一个拼音表,包含所有汉字的发音,这个可以通过转换全拼输入法的编码库得到,这里仅举了一个简单的例子.
--*/

[转]汉字转拼音的存储过程--创建汉字拼音库
[转]汉字转拼音的存储过程
create table YingShe(CHR  char(2),PY varchar(10))
[转]汉字转拼音的存储过程
insert YingShe 
[转]汉字转拼音的存储过程
select '','chang'
[转]汉字转拼音的存储过程 
union all select '','zhang'
[转]汉字转拼音的存储过程 
union all select '','cheng'
[转]汉字转拼音的存储过程 
union all select '','kel'
[转]汉字转拼音的存储过程 
union all select '','ji'
[转]汉字转拼音的存储过程 
union all select '','jin'
[转]汉字转拼音的存储过程 
union all select '','li'
[转]汉字转拼音的存储过程 
union all select '','zhang'
[转]汉字转拼音的存储过程 
union all select '','gong'
[转]汉字转拼音的存储过程 
union all select '','si'
[转]汉字转拼音的存储过程

相关文章:

  • 2022-01-28
猜你喜欢
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
相关资源
相似解决方案