有辅助拼音表的情况下,如何获取字段的拼音简码?(多音字需考虑)

不穿内裤的超人 不穿内裤的超人 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

id hz sm
1 一 y
2 丁 d
3 丁 z
4 丂 k
5 丂 q
6 丂 y
7 七 q
8 丄 s
9 丅 x
10 丆 y
11 丆 n
12 丆 o
13 丆 m


表tmp
id name spellshort
1 重楼
2 丹参
3 乘以


更新后:
id name spellshort
1 重楼 cl;zl
2 丹参 ds;dc
3 乘以 cy,sy

如果不是多音字,拼音简码就生成一个,多音字按照有几个多音字,按;分开,生成多个
能否实现?我目前能写出调用第一个找到的声母的方法,但是多音字不处理很难弄。
declare @word nchar(1),@PY nvarchar(4000),@str nvarchar(4000) 
set @str='中文字符'
set @PY=''
while len(@str)>0
begin
set @word=left(@str,1)
set @PY=@PY+(select left(sm,1) from test..hypy a where a.hz=@word )
set @str=right(@str,len(@str)-1)
end
select @PY
zwzf


declare @word nchar(1),@PY nvarchar(4000),@str nvarchar(4000) 
set @str='中文字符重'
set @PY=''
while len(@str)>0
begin
set @word=left(@str,1)
set @PY=@PY+(select left(sm,1) from test..hypy a where a.hz=@word )
set @str=right(@str,len(@str)-1)
end
select @PY

消息 512,级别 16,状态 1,第 10 行
子查询返回的值不止一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。

(1 行受影响)
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
不穿内裤的超人
疑难问题 22,298 成员 121,727 内容