Sqlserver query data by Pinyin and sqlserver pinyin
Directly execute the following functions and pass the corresponding parameters in the background to query data.
Create 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 'no', 'A' union all select '8 ', 'B' union all select 'running', 'C' union all select 'running', 'D' union all select 'running', 'E' union all select 'out ', 'F' union all select 'hour', 'G' union all select 'haid', 'H' union all select ', 'J' union all select 'hour ', 'K' union all select 'distinct', 'L' union all select 'distinct', 'M' union all select 'distinct', 'n' union all select ', 'o' union all select 'hour', 'P' union all select '7', 'q' union all select 'hour', 'R' union all select 'hour ','s 'Union all select 'He', 't'union all select 'shanghai', 'w' union all select 'Xi ', 'x' union all select' ya ', 'y' union all select 'hour', '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 --- query --- select * from [pactinfo] where left (dbo. f_GetPy (pactname), 1) = 'Z'