SQL Server gets phonetic initials of Chinese character strings _mssql

Source: Internet
Author: User
Tags strlen
Copy Code code as follows:

CREATE function fgetpy (@str varchar (500) = ')
Returns varchar (500)
As
Begin
declare @strlen int, @return varchar, @ii int
DECLARE @c nchar (1), @chn nchar (1)
Select @strlen =len (@str), @return = ', @ii =0
Set @ii =0
While @ii < @strlen
Begin
Select @ii = @ii +1, @chn =substring (@str, @ii, 1)
If @chn >= ' Acridine '
Select @c = char (count (*) +63) from (
Select top of * FROM (
Select CHN = ' Acridine '
UNION ALL select ' Eight '
UNION ALL select ' Cha '
UNION ALL SELECT ' 咑 '
UNION ALL SELECT ' 妸 '
UNION ALL SELECT ' Send '
UNION ALL SELECT ' There '
UNION ALL SELECT ' Hafnium '
UNION ALL SELECT ' No '--because have no ' i '
UNION ALL SELECT ' No '
UNION ALL select ' Ka '
UNION ALL select ' garbage '
UNION ALL SELECT ' 嘸 '
UNION ALL SELECT ' 拏 '
UNION ALL select ' Oh '
UNION ALL SELECT ' 妑 '
UNION ALL select ' Seven '
UNION ALL SELECT ' 呥 '
UNION ALL select ' sa '
UNION ALL SELECT ' he '
UNION ALL SELECT ' 屲 '--no ' u '
UNION ALL SELECT ' 屲 '--no ' V '
UNION ALL SELECT ' 屲 '
UNION ALL select ' XI '
UNION ALL select ' Ya '
UNION ALL SELECT ' 帀 '
UNION ALL Select @chn
) as a
ORDER by CHN COLLATE Chinese_prc_ci_as) as B
where B.chn <= @chn
else set @c= @chn
Set @return = @return +@c
End
Return (@return)
End
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.