国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > 綜合 > 正文

取得拼音字頭的存儲(chǔ)過程

2024-07-21 02:10:36
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

-- =============================================
-- create scalar function (nwgetpyfirst)
-- =============================================
if exists (select *
 from   sysobjects
 where  name = n'nwgetpyfirst')
 drop function nwgetpyfirst
go

create function nwgetpyfirst
(@str varchar(500) = '')
returns varchar(500)
as
begin
 declare @strlen int,
  @return varchar(500),
  @ii int,
  @c char(1),
  @chn nchar(1)
 --//初始化變量
 declare @pytable table(
 chn char(2) collate chinese_prc_cs_as not null,
 py char(1) collate chinese_prc_cs_as null,
 primary key (chn)
   )
 insert into @pytable values('吖', 'a')
 insert into @pytable values('八', 'b')
 insert into @pytable values('嚓', 'c')
 insert into @pytable values('咑', 'd')
 insert into @pytable values('妸', 'e')
 insert into @pytable values('發(fā)', 'f')
 insert into @pytable values('旮', 'g')
 insert into @pytable values('鉿', 'h')
 insert into @pytable values('丌', 'i')
 --insert into @pytable values('丌', 'j')
 insert into @pytable values('咔', 'k')
 insert into @pytable values('垃', 'l')
 insert into @pytable values('嘸', 'm')
 insert into @pytable values('拏', 'n')
 insert into @pytable values('噢', 'o')
 insert into @pytable values('妑', 'p')
 insert into @pytable values('七', 'q')
 insert into @pytable values('呥', 'r')
 insert into @pytable values('仨', 's')
 insert into @pytable values('他', 't')
 insert into @pytable values('屲', 'u')
 --insert into @pytable values('屲', 'v')
 --insert into @pytable values('屲', 'w')
 insert into @pytable values('夕', 'x')
 insert into @pytable values('丫', 'y')
 insert into @pytable values('帀', 'z')

 select @strlen = len(@str), @return = '', @ii = 0
 --//循環(huán)整個(gè)字符串,用拼音的首字母替換漢字
 while @ii < @strlen
 begin
  select @ii = @ii + 1, @chn = substring(@str, @ii, 1)
  if @chn > 'z' --//檢索輸入的字符串中有中文字符
   select @c = max(py)
   from @pytable
   where chn <= @chn
  else
   set @[email protected]
 
  set @[email protected][email protected]
 end
 return @return
end
go

-- =============================================
-- example to execute function
-- =============================================
select dbo.nwgetpyfirst('夢(mèng)想國(guó)度'), dbo.nwgetpyfirst('noctwolf分享源碼'), dbo.nwgetpyfirst('')
go

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 沈阳市| 保亭| 高尔夫| 酒泉市| 和田市| 罗山县| 清流县| 九龙坡区| 成武县| 博野县| 沂源县| 洛宁县| 鹤峰县| 孟州市| 武威市| 房产| 乌拉特中旗| 孝感市| 海盐县| 玉门市| 海安县| 武汉市| 同仁县| 额尔古纳市| 西藏| 辽宁省| 弋阳县| 三亚市| 织金县| 安多县| 曲水县| 西畴县| 贡山| 略阳县| 青阳县| 兴海县| 潼南县| 翁源县| 开化县| 南投市| 萨嘎县|