Sort 26 letters, Chinese characters, and first letter
Source: Internet
Author: User
Alter function f_getpy (@ STR nvarchar (4000 ))
Returns nvarchar (4000)
As
Begin
Declare @ strlen int, @ Re nvarchar (4000)
Declare @ t table (CHR nchar (1) Collate chinese_prc_ci_as, letter nchar (1 ))
Insert into @ T (CHR, letter)
Select 'ay', 'A' Union all select '8', 'B' Union all
Select 'accept', 'C' Union all select 'accept', 'D' Union all
Select 'hangzhou', 'E' Union all select 'hangzhou', 'F' Union all
Select 'hangzhou', 'G' Union all select 'haid', 'H' Union all
Select ', 'J' Union all select 'hour', 'K' Union all
Select 'hangzhou', 'L' Union all select 'hangzhou', 'M' Union all
Select 'hour', 'n' Union all select 'ou', 'O' Union all
Select 'hangzhou', 'P' Union all select '7', 'q' Union all
Select 'hour', 'R' Union all select 'hour', 's' Union all
Select 'others', 't'union all select 'hour', 'w' Union all
Select 'Xi ', 'x' Union all select 'ya', 'y' Union all
Select 'running', 'Z'
Select @ strlen = Len (@ Str), @ Re =''
While @ strlen> 0
Begin
Select top 1 @ Re = letter + @ Re, @ strlen = @ strlen-1
From @ t a where CHR <= substring (@ STR, @ strlen, 1)
Order by CHR DESC
If @ rowcount = 0
Select @ Re = substring (@ STR, @ strlen, 1) + @ Re, @ strlen = @ strlen-1
End
Return (@ Re)
End
Go
Create proc pr_getpy
@ Firstword nchar (1)
As
Select * From aspnet_users where @ firstword = substring (DBO. f_getpy (username), 1, 1)
Go
Exec pr_getpy @ firstword = 'Z'
Write it down first.
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