国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 西昌市| 年辖:市辖区| 陕西省| 新竹市| 蒙自县| 海阳市| 贵阳市| 张家川| 松溪县| 无极县| 疏勒县| 治多县| 禹州市| 鄂州市| 东宁县| 长子县| 祁东县| 江口县| 韩城市| 福州市| 长兴县| 杂多县| 祁东县| 竹山县| 阳西县| 武强县| 泸水县| 呼玛县| 金平| 龙川县| 宕昌县| 图木舒克市| 罗源县| 巴塘县| 蛟河市| 时尚| 安吉县| 海林市| 常宁市| 桑植县| 张家港市|