上一篇:图片下拉选择器的制作 >>
获得汉字字符串的首字母
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 select ‘’八‘’
union all select ‘’嚓‘’
union all select ‘’咑‘’
union all select ‘’妸‘’
union all select ‘’发‘’
union all select ‘’旮‘’
union all select ‘’铪‘’
union all select ‘’丌‘’ --because have no ‘’i‘’
union all select ‘’丌‘’
union all select ‘’咔‘’
union all select ‘’垃‘’
union all select ‘’嘸‘’
union all select ‘’拏‘’
union all select ‘’噢‘’
union all select ‘’妑‘’
union all select ‘’七‘’
union all select ‘’呥‘’
union all select ‘’仨‘’
union all select ‘’他‘’
union all select ‘’屲‘’ --no ‘’u‘’
union all select ‘’屲‘’ --no ‘’v‘’
union all select ‘’屲‘’
union all select ‘’夕‘’
union all select ‘’丫‘’
union all select ‘’帀‘’
union all select @chn) as a
order by chn COLLATE Chinese_PRC_CI_AS
) as b
else set @c=‘’a‘’
set @return=@return+@c
end
return(@return)
end
go
--测试
select dbo.fgetpy(‘’魏保光‘’) as 姓名拼音,dbo.fgetpy(‘’ab中c国人‘’) as 中国人
select dbo.fgetpy(‘’刘子良‘’) as 姓名拼音,dbo.fgetpy(‘’ab中c国人‘’) as 中国人
select dbo.fgetpy(‘’吴过‘’) as 姓名拼音,dbo.fgetpy(‘’ab中c国人‘’) as 中国人
select dbo.fgetpy(‘’东北‘’) as 姓名拼音,dbo.fgetpy(‘’ab中c国人‘’) as 中国人
--删除拼音函数
drop function fgetpy
下一篇:循序渐进学做留言簿-给留言簿添加在线留言编辑功能(二) >>
相关文章:
- · ASP判断文件地址是否有效!
- · 用Asp隐藏文件路径实现防盗链
- · Asp:Cookies应用指南,详细代码及教程
- · asp编程:召开自己的新闻发布会
- · 如何实现真正的动态包含
- · 用静态URL显示动态网页
- · 页顶导航条示例
- · 简单析取html文件实例
- · 树目录菜单的制作
- · 用ASP创建Word文件
- · ASP翻页的实现方法
- · 用ASP建立网站地图
- · 获得ASP的中文日期字符串
- · 利用索引服务和ASP建立面向整个网站搜索程序
- · ASP+中不再依赖Cookie的设定方法
- · 负载平衡环境下的SESSION管理
- · ASP应用中数据库记录的选取与过滤
- · ASP的多条件动态查询
- · 优化ASP应用程序技巧四则
- · ASP中ActiveX控件的内嵌及调用
- · 在win2003上用cdo代替CDONTS发邮件
- · Freetextbox的使用
- · asp提供在线文章翻译的功能
- · 关于Request
- · 基于B/S下的IC智能卡的安全问题
- · ASP小偷偷取地址并生成html
- · 求助关于远程访问ACCESS数据库的问题
- · Forms验证中的roles
- · 一个比较精辟的索引文章
- · T-SQL: 17 个与日期时间相关的自定义函数(UDF)
- · 限制某段IP地址
- · 调用winrar压缩文件夹
- · ASP做的剪包锤游戏
- · 如何在ASP+中使用自定义的PAGELET
- · 利用ASP编写动态回复表单
- · 用ASP和javascript实现网页上的动态分级目录
- · 在Windows 2000中配置ASP开发环境
- · ASP数据库编程SQL常用技巧
