SQL function: Chinese characters are converted to pinyin

xiaoxiao2021-03-06  62

SQL database customs a function writes the following code

The function is to get the Chinese characters

as follows:

Create function fun_getpy (@str nvarchar (4000)) Returns nvarchar (4000) asbegindeclare @Word nchar (1), @ py nvarchar (4000) set @py = 'while g (@str)> 0beginset @ word = left (@ Str, 1) - If the Chinese character character, return to the original character set @ py = @ py (@Word) Between 19968 and 19968 20901Then (SELECT 'A' AS PY, N '骜 'As Wordunion All Select' B ', N' Book 'Union All Select' c ', N' Wrong 'Union All Select' D ', N' 鵽 'Union All Select' E ', N' 樲 'Union All Select 'F', n '鳆' union all succ 'g', n '腂' union all select 'h', n '夻' union all select 'j', n '攈' union all succ 'k', n '穒 'Union All Select' L ', N' 鱳 'Union All Select' M ', N' 旀 'Union All Select' N ', N' 桛 'Union All Select' O ', N' 沤 'Union All Select' P ', N' Exposure 'Union All Select' Q ', N' 囕 'Union All Select' R ', N' 鶸 'Union All Select' S ', N' 蜶 'Union All Select' T ', N' 箨'Union All Select' W ', N' 鹜 'Union All Select' X ', N' 鑂 'Union All Select' Y ', N' Rhyme 'Union All Select' Z ', N' 咗 ') T Where Word> @ Word Collate Chinese_PRC_CS_AS_KS_WS ORDER BY PY ASC) ELSE @Word End End @ Str = Right (@ Str, Len (@STR) -1) endreturn @PYEND

- Function call instance: Select dbo.fun_getpy ('"People's Republic') results are: zhrmghg

转载请注明原文地址:https://www.9cbs.com/read-111104.html

New Post(0)