我想知道 有没有这样的C# 插件可以用大的拼音字母查询数据库里面的数据

来源:百度知道 编辑:UC知道 时间:2024/05/31 08:57:14
比如 我的数据库中有 CH
我就可以查到以CH开头的所有产品
还有叫"翠花"的客户或者是店里的员工
关于相应字库的使用也请教我一下
我有急用
谢谢大侠的照顾

如果数据库是SQL Server的话,可以给你一个SQL函数,它可以将汉字转换成拼音大写首字母,将英文转换成a

/*-1.-获得汉字字符串的首字母

根据大力的贴子改成.将大力的两个函数合并成了一个函数.
可以应用于助记码的查询
--转载(最早见于j9988的发表,具体原作者不明)--*/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fGetPy]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fGetPy]
GO

--创建取拼音函数
create function fGetPy(@Str varchar(500)='')
returns varchar(500)
as
begin
declare @strlen int,@return varchar(500),@ii int
declare @n int,@c char(1),@chn nchar(1)

select @strlen=len(@str),@return='',@ii=0
set @ii=0
while @ii<@strlen
begin
select @ii=@ii+1,@n=63,@chn=substring(@str,@ii,1)
if @chn>'z'
select @n = @n +1
,@c = case chn when @chn then char(@n) else @c end
from(
select top 27 * from (
select chn = '吖'
union all sel