当前位置:Gxlcms > 数据库问题 > sqlsever 判断某个字段出现重复的字母或字符

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

时间:2021-07-01 10:21:17 帮助过:7人阅读

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


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   

人气教程排行