Get the App
SLTechnology News&Howtos  ›  Database  › 

Acquisition of Chinese character mnemonic codes by sqlserver

Shulou Source: shulou.com Published: 2022-06-01 04:55:59 09月24日 Update

First of all, create a function whose function is to get the first letter of Chinese phonetic alphabet.

Go

If exists (select * from sysobjects where name='fun_getPY' and xtype='Fn')

Begin

Drop function fun_getPY

End

Go

Create function fun_getPY (@ str nvarchar (4000))

/ * get the first letter of Chinese pinyin * /

Returns nvarchar (4000)

As

Begin

Declare @ word nchar (1), @ PY nvarchar (4000)

Set @ PY=''

While len (@ str) > 0

Begin

Set @ word=left (@ str,1)

If it is not a Chinese character, the original character is returned.

Set @ PY=@PY+ (case when unicode (@ word) between 19968 and

Then (select top 1 PY from (

Select'A'as PY,N' girls'as word

Union all select 'Bamboo Magazine N' Book'

Union all select 'Cummings'.

Union all select 'Dracula Magnum N'Lou'

Union all select'Efficient Magnum N'Fountain'

Union all select'Fengjingjinghuo'.

Union all select'Grain Magnum N'Our'

Union all select'Hangjia Magnum N'Fang'

Union all select'Jun Jun Magi N'Qing'

Union all select 'Kendall Magnum N'Yun'

Union all select 'Lindsey'.

Union all select'M é cor Magi N'em'

Union all select 'Nice, Magnum,'

Union all select 'Olympian'.

Union all select'Please Magnum N 'expose'

Union all select 'Qiang Magi N'Qing'

Union all select'Rongjia Magnum N'Fountain'

Union all select'Scripture Magnum N'em'

Union all select'Thoujinghorn 'ice'

Union all select 'Warriors'.

Union all select 'Xanthology, Magnum N'.

Union all select 'Yizhi, Magnum N'

Union all select 'Zhai'.

) T

Where word > = @ word collate Chinese_PRC_CS_AS_KS_WS

Order by PY ASC) else @ word end)

Set @ str=right (@ str,len (@ str)-1)

End

Return @ PY

End

Go

-- function call example 1: generate mnemonic codes for specified characters

Select dbo.fun_getPY ('China-Zhengzhou') FhelperCode

Tags: Chinese characters characters functions letters pinyin functions examples that is Chinese Zhengzhou generated pinyin letters Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Redmi OPPO Reno MariaDB Shulou Technology