码迷,mamicode.com
首页 > 数据库 > 详细

sqlsever 判断某个字段出现重复的字母或字符

时间:2018-02-02 20:20:36      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:字符   int   end   pos   判断   出现   fun   turn   gpo   

-------下面使用标量值函数判断  出现重复的个数


create function fn_str_times
(
@str varchar(1000),--原子符串
@indexstr varchar(20)--查找的字符
)
returns int
as
begin
declare @findlen int
declare @times int
set @findlen=LEN(@indexstr)
set @times=0
while(charindex(@indexstr,@str))>0
BEGIN
set @str=SUBSTRING(@str,CHARINDEX(@indexstr,@str)+@findlen,len(@str))
set @times=@times+1
end
 
return @times
end

sqlsever 判断某个字段出现重复的字母或字符

标签:字符   int   end   pos   判断   出现   fun   turn   gpo   

原文地址:https://www.cnblogs.com/pang572936554/p/8406459.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!