mssql

推荐列表 站点导航

当前位置:首页 > 数据库 > mssql >

sqlserver 快速生成汉字的首拼字母的函数(经典)

来源:网络整理  作者:网络  发布时间:2020-12-08 19:58
经常要对姓名按拼音搜索,所以需要做如下函数来快速获取首拼,需要的朋友可以参考下...
union all select 'E',N'樲'
union all select 'Q',N'囕'
select top 1 PY
from
end
as
)
end)
else @word
SET ANSI_NULLS ON
union all select 'S',N'蜶'
begin
GO
union all select 'M',N'旀'
union all select 'P',N'曝'
SET QUOTED_IDENTIFIER ON
end
*/
USE [tempdb]
order by PY ASC
select dbo.[fun_getPY]('中国人') 首拼
/*
/****** Object: UserDefinedFunction [dbo].[fun_getPY] Script Date: 05/23/2012 18:03:45 ******/


union all select 'O',N'漚'
select 'A' as PY,N'驁' as word
union all select 'L',N'鱳'

while len(@str)>0
set @PY=''

复制代码 代码如下:

declare @word nchar(1),@PY nvarchar(4000)
union all select 'R',N'鶸'
union all select 'G',N'腂'
ALTER function [dbo].[fun_getPY]
)
@str nvarchar(4000)
set @str=right(@str,len(@str)-1)
(
union all select 'T',N'籜'
获取汉字的首拼音
where word>=@word collate Chinese_PRC_CS_AS_KS_WS
set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
union all select 'D',N'鵽'
union all select 'J',N'攈'
调用如下:
return upper(@PY)
) T

复制代码 代码如下:

union all select 'X',N'鑂'
union all select 'N',N'桛'
then (
begin
union all select 'Y',N'韻'
set @word=left(@str,1)


如果是非汉字字符
GO
GO
union all select 'Z',N'咗'
union all select 'H',N'夻'

union all select 'B',N'簿'
returns nvarchar(4000)
union all select 'W',N'鶩'
union all select 'F',N'鰒'
union all select 'K',N'穒'
--如果非汉字字符,返回原字符

(
union all select 'C',N'錯'

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/sql/mssql/1536.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

sqlserver 快速生成汉字的首拼字母的函数(经典)

2020-12-08 编辑:网络

union all select 'E',N'樲'
union all select 'Q',N'囕'
select top 1 PY
from
end
as
)
end)
else @word
SET ANSI_NULLS ON
union all select 'S',N'蜶'
begin
GO
union all select 'M',N'旀'
union all select 'P',N'曝'
SET QUOTED_IDENTIFIER ON
end
*/
USE [tempdb]
order by PY ASC
select dbo.[fun_getPY]('中国人') 首拼
/*
/****** Object: UserDefinedFunction [dbo].[fun_getPY] Script Date: 05/23/2012 18:03:45 ******/


union all select 'O',N'漚'
select 'A' as PY,N'驁' as word
union all select 'L',N'鱳'

while len(@str)>0
set @PY=''

复制代码 代码如下:

declare @word nchar(1),@PY nvarchar(4000)
union all select 'R',N'鶸'
union all select 'G',N'腂'
ALTER function [dbo].[fun_getPY]
)
@str nvarchar(4000)
set @str=right(@str,len(@str)-1)
(
union all select 'T',N'籜'
获取汉字的首拼音
where word>=@word collate Chinese_PRC_CS_AS_KS_WS
set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
union all select 'D',N'鵽'
union all select 'J',N'攈'
调用如下:
return upper(@PY)
) T

复制代码 代码如下:

union all select 'X',N'鑂'
union all select 'N',N'桛'
then (
begin
union all select 'Y',N'韻'
set @word=left(@str,1)


如果是非汉字字符
GO
GO
union all select 'Z',N'咗'
union all select 'H',N'夻'

union all select 'B',N'簿'
returns nvarchar(4000)
union all select 'W',N'鶩'
union all select 'F',N'鰒'
union all select 'K',N'穒'
--如果非汉字字符,返回原字符

(
union all select 'C',N'錯'

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/sql/mssql/1536.shtml

相关文章

风云图片

推荐阅读

返回mssql频道首页