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

Posted 王子先生

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqlsever 判断某个字段出现重复的字母或字符相关的知识,希望对你有一定的参考价值。

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


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)[email protected],len(@str))
set @[email protected]+1
end
 
return @times
end

以上是关于sqlsever 判断某个字段出现重复的字母或字符的主要内容,如果未能解决你的问题,请参考以下文章