w-hua-home
USE [master] 
GO
/****** Object:  UserDefinedFunction [dbo].[CharRepeat]    Script Date: 04/06/2016 17:32:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
--
 返回字符串中某字符出现次数,返回结果为INT,@str 字符串 @sub 目标字符,源码来源于百度搜索
--
 =============================================
ALTER function [dbo].[CharRepeat](@str varchar(8000),@sub varchar(50))
returns int
as
begin
    declare @pos int,@n int

    select @n=0@pos=charindex(@sub,@str)

    while(@pos<>0)
    begin
        select @str=right(@str,len(@str)-@pos),@pos=charindex(@sub,@str),@n=@n+1
    end

    return(@n)
end

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
猜你喜欢
  • 2021-07-12
  • 2022-12-23
  • 2021-12-03
  • 2022-02-03
  • 2021-12-22
  • 2022-12-23
相关资源
相似解决方案