当前位置: 代码迷 >> Sql Server >> 想将中文转化问拼音,出现有关问题了,帮忙看看
  详细解决方案

想将中文转化问拼音,出现有关问题了,帮忙看看

热度:35   发布时间:2016-04-27 20:50:39.0
想将中文转化问拼音,出现问题了,帮忙看看
需要将字段name由中文转化问拼音,大家帮忙看看,有问题了,
declare   @hanzi   nvarchar(500),
                @pinyin     nvarchar(20),
                @name   nvarchar(500),
                @nameen   nvarchar(1000),
                @i   int,
                @conseq     int
              set   @i=1
declare   topinyin   cursor   for   select   name,conseq   ,nameen   from   conmas   where   conseq <1000   order   by   conseq/*name为中文字段,conseq为主键,int,nameen为name转化为拼音的字段,默认值为 ' '*/
                      open   topinyin
                              fetch   next   from   topinyin   into   @name,@conseq,@nameen
                            print   @conseq
                      while   @@FETCH_STATUS   =   0
                            Begin
                                    while     @i <=len(@name)
                                    begin  
                                        select   @hanzi=   substring(@name,@i,1)  
                                select   @pinyin=   拼音   from   汉字拼音表     where     patindex(   '% '[email protected]+ '% ',汉字) <> 0
                                              update   conmas   set   nameen=nameen+ '   '[email protected]   where       [email protected]
                                      select   @[email protected]+1  
                                      end  
                              fetch   next   from   topinyin   into   @name,@conseq,@nameen
                        return
                    End
    CLOSE   topinyin
deallocate   topinyin/*
汉字拼音表格式为
拼音     汉字
a           <所有发音问a的汉字>
ai         <所有发音问ai的汉字> */




------解决方案--------------------
while @@FETCH_STATUS = 0
Begin
set @i=1
  相关解决方案