自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SQL漢字轉(zhuǎn)換為拼音的函數(shù)

數(shù)據(jù)庫 SQL Server
SQL中有許多功能強(qiáng)大的函數(shù),下面為您介紹sql中漢字轉(zhuǎn)換為拼音的函數(shù),供您參考,希望能夠?qū)δ兴鶐椭?/div>

SQL中有多種的函數(shù),下面為您介紹sql中漢字轉(zhuǎn)換為拼音的函數(shù),供您參考。數(shù)據(jù)庫中先自定義一個(gè)函數(shù),再把下面代碼寫進(jìn)去,功能是得到漢字拼音首字母:

如下:

 

01 create function fun_getPY(@str nvarchar(4000))
02 returns nvarchar(4000)
03 as
04 begin
05 declare @word nchar(1),@PY nvarchar(4000)
06 set @PY=''
07 while len(@str)>0
08 begin
09 set @word=left(@str,1)
10 --如果非漢字字符,返回原字符
11 set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
12 then (select top 1 PY from (
13 select 'A' as PY,N'驁' as word
14 union all select 'B',N'簿'
15 union all select 'C',N'錯(cuò)'
16 union all select 'D',N'鵽'
17 union all select 'E',N'樲'
18 union all select 'F',N'鰒'
19 union all select 'G',N'腂'
20 union all select 'H',N'夻'
21 union all select 'J',N'攈'
22 union all select 'K',N'穒'
23 union all select 'L',N'鱳'
24 union all select 'M',N'旀'
25 union all select 'N',N'桛'
26 union all select 'O',N'漚'
27 union all select 'P',N'曝'
28 union all select 'Q',N'囕'
29 union all select 'R',N'鶸'
30 union all select 'S',N'蜶'
31 union all select 'T',N'籜'
32 union all select 'W',N'鶩'
33 union all select 'X',N'鑂'
34 union all select 'Y',N'韻'
35 union all select 'Z',N'咗'
36 ) T 
37 where word>=@word collate Chinese_PRC_CS_AS_KS_WS 
38 order by PY ASC) else @word end)
39 set @str=right(@str,len(@str)-1)
40 end
41 return @PY
42 end

 

--函數(shù)調(diào)用實(shí)例:
select dbo.fun_getPY('中華人民共和國')
結(jié)果都為:ZHRMGHG

 

【編輯推薦】

SQL中的ISNULL函數(shù)介紹

Sql語言中的日期格式化函數(shù)getDate()

詳解SQL中的SUBSTRING函數(shù)

SQL中的CHARINDEX函數(shù)

SQL中自定義函數(shù)的存儲(chǔ)過程的區(qū)別

責(zé)任編輯:段燃 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-07-21 17:02:35

SQL Server取

2022-09-24 16:53:05

Python工具辦公

2010-07-01 16:52:53

SQL Server數(shù)

2010-09-09 10:32:24

SQL函數(shù)拼音

2010-10-27 13:25:33

Oracle查詢

2010-10-25 10:20:33

ORACLE函數(shù)

2010-07-09 17:07:14

SQL Server數(shù)

2010-07-12 08:36:35

SQL Server數(shù)

2010-09-14 17:08:11

SQL函數(shù)

2010-10-14 16:45:54

MySQL查詢

2024-11-12 10:09:59

Go語言第三方庫

2010-10-27 13:35:15

Oracle查詢

2010-10-27 13:39:34

Oracle查詢

2010-09-06 17:22:01

SQL函數(shù)

2020-12-03 09:33:58

前端開發(fā)工具

2010-09-06 17:35:43

SQL函數(shù)

2010-09-06 16:25:46

SQL函數(shù)

2009-07-21 17:26:09

Scala本地函數(shù)

2010-11-26 14:09:32

MySQL內(nèi)置函數(shù)

2011-07-11 10:42:23

SQL數(shù)據(jù)庫橫向數(shù)據(jù)縱向字段
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)