Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The function example usage of quickly generating the first spelling letter of Chinese characters by sqlserver

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "the function example usage of sqlserver to quickly generate the first spelling letters of Chinese characters". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The copy code is as follows:

USE [tempdb] GO / * Object: UserDefinedFunction [dbo]. [fun_getPY] Script Date: 05Universe 23max 18:03:45 * / SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO / * obtain the first pinyin of Chinese characters if it is a non-Chinese character * / ALTER function [dbo]. [fun_getPY] (@ str nvarchar (4000)) 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 non-Chinese characters Returns the original character set @ PY=@PY+ (case when unicode (@ word) between 19968 and 19968mm 20901then (select top 1 PY from (select'A'as PY,N' as word union all select 'then) (select top 1 PY from (select' A' as PY,N'')'as word union all select 'then'). N' union all select 'union all select' KnowledgeDifferentN' union all select 'union all select' Lindsay, N'union all select 'Trends, N`union all select' Trends, N' union all select 'Wales, N' union all select' Wales, N' union all select'X' 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 upper (@ PY) end

The copy code is as follows:

Select dbo. [fun _ getPY] ('Chinese')

Results: ZGR

This is the end of the content of "the function example usage of quickly generating the first spelling letters of Chinese characters by sqlserver". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report