设为首页 加入收藏

TOP

SQL SERVER 得到汉字首字母函数四版全集(一)
2014-11-24 03:02:17 来源: 作者: 【 】 浏览:6
Tags:SQL SERVER 得到 汉字 字母 函数四 全集
--创建取汉字首字母函数(第三版)
create function [dbo].[f_getpy_V3]
(
@col varchar(1000)
)
returns varchar(1000)
as
begin
declare @cyc int,@len int,@sql varchar(1000),@char varbinary(20)
select @cyc = 1,@len = len(@col),@sql = ''
while @cyc <= @len
begin
select @char = cast(substring(@col, @cyc, 1) as varbinary)
declare @maco table (bcode varbinary(20),ecode varbinary(20),letter varchar(10))
insert into @maco
select 0XB0A1,0XB0C4,'A' union all
select 0XB0C5,0XB2C0,'B' union all
select 0XB2C1,0XB4ED,'C' union all
select 0XB4EE,0XB6E9,'D' union all
select 0XB6EA,0XB7A1,'E' union all
select 0XB7A2,0XB8C0,'F' union all
select 0XB8C1,0XB9FD,'G' union all
select 0XB9FE,0XBBF6,'H' union all
select 0XBBF7,0XBFA5,'J' union all
select 0XBFA6,0XC0AB,'K' union all
select 0XC0AC,0XC2E7,'L' union all
select 0XC2E8,0XC4C2,'M' union all
select 0XC4C3,0XC5B5,'N' union all
select 0XC5B6,0XC5BD,'O' union all
select 0XC5BE,0XC6D9,'P' union all
select 0XC6DA,0XC8BA,'Q' union all
select 0XC8BB,0XC8F5,'R' union all
select 0XC8F6,0XCBF9,'S' union all
select 0XCBFA,0XCDD9,'T' union all
select 0XCDDA,0XCEF3,'W' union all
select 0XCEF4,0XD1B8,'X' union all
select 0XD1B9,0XD4D0,'Y' union all
select 0XD4D1,0XD7F9,'Z'
select top 1 @sql=@sql+letter from @maco where @char between bcode and ecode
set @cyc = @cyc + 1
end
return @sql
end
go
--创建取汉字首字母函数(第四版)
create function [dbo].[f_getpy_V4]
(
@col varchar(1000)
)
returns varchar(1000)
begin
declare @cyc int,@len int,@sql varchar(1000),@char varbinary(20)
select @cyc = 1,@len = len(@col),@sql = ''
while @cyc <= @len
begin
select @char = cast(substring(@col, @cyc, 1) as varbinary)
if @char>=0XB0A1 and @char<=0XB0C4 set @sql=@sql+'A'
else if @char>=0XB0C5 and @char<=0XB2C0 set @sql=@sql+'B'
else if @char>=0XB2C1 and @char<=0XB4ED set @sql=@sql+'C'
else if @char>=0XB4EE and @char<=0XB6E9 set @sql=@sql+'D'
else if @char>=0XB6EA and @char<=0XB7A1 set @sql=@sql+'E'
else if @char>=0XB7A2 and @char<=0XB8C0 set @sql=@sql+'F'
else if @char>=0XB8C1 and @char<=0XB9FD set @sql=@sql+'G'
else if @char>=0XB9FE and @char<=0XBBF6 set @sql=@sql+'H'
else if @char>=0XBBF7 and @char<=0XBFA5 set @sql=@sql+'J'
else if @char>=0XBFA6 and @char<=0XC0AB set @sql=@sql+'K'
else if @char>=0XC0AC and @char<=0XC2E7 set @sql=@sql+'L'
else if @char>=0XC2E8 and @char<=0XC4C2 set @sql=@sql+'M'
else if @char>=0XC4C3 and @char<=0XC5B5 set @sql=@sql+'N'
else if @char>=0XC5B6 and @char<=0XC5BD set @sql=@sql+'O'
else if @char>=0XC5BE and @char<=0XC6D9 set @sql=@sql+'P'
else if @char>=0XC6DA and @char<=0XC8BA set @sql=@sql+'Q'
else if @char>=0XC8BB and @char<=0XC8F5 set @sql=@sql+'R'
else if @char>=0XC8F6 and @char<=0XCBF9 set @sql=@sql+'S'
else if @char>=0XCBFA and @char<=0XCDD9 set @sql=@sql+'T'
else if @char>=0XCDDA and @char<=0XCEF3 set @sql=@sql+'W'
else if @char>=0XCEF4 and @char<=0XD1B8 set @sql=@sql+'X'
else if @char>=0XD1B9 and @char<=0XD4D0 set @sql=@sql+'Y'
else if @char>=0XD4D1
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇获取系统日期与某一个日期之间天.. 下一篇SQL语句获取所有数据库名、表名、..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Python中文网 - 人生 (2025-12-24 18:49:47)
·【整整648集】这绝对 (2025-12-24 18:49:44)
·Python超详细一条龙 (2025-12-24 18:49:42)
·【超详细】JDK 下载 (2025-12-24 18:19:32)
·Java_百度百科 (2025-12-24 18:19:29)