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

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

取得拼音字頭的存儲過程

2024-07-21 02:31:27
字體:
供稿:網(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)整個字符串,用拼音的首字母替換漢字
 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 @c=@chn
 
  set @return=@return+@c
 end
 return @return
END
GO

-- =============================================
-- Example to execute function
-- =============================================
SELECT dbo.NWGetPYFirst('夢想國度'), dbo.NWGetPYFirst('noctwolf分享源碼'), dbo.NWGetPYFirst('')
GO


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 金乡县| 阳泉市| 镇康县| 铜鼓县| 临沧市| 伊春市| 岗巴县| 巴中市| 凤阳县| 昌都县| 苏尼特左旗| 望都县| 项城市| 沐川县| 黄平县| 德格县| 云霄县| 无极县| 霍州市| 牙克石市| 淮南市| 彭泽县| 五峰| 剑阁县| 乾安县| 香港| 扎囊县| 衡水市| 长治市| 铁岭市| 舟山市| 仪陇县| 司法| 翁源县| 鄂温| 灵台县| 南澳县| 揭西县| 望都县| 丹阳市| 宜川县|