CREATE FUNCTION Occurs (
@findstr varchar(100),
@mystr varchar(100)
)
RETURNS int
AS
BEGIN
DECLARE @cnt int
SET @cnt = 0
WHILE CHARINDEX(@findstr, @mystr, 1) <> 0
BEGIN
SET @cnt = @cnt + 1
SET @mystr = SUBSTRING(@mystr, CHARINDEX(@findstr, @mystr, 1) + 1, 100)
END
RETURN(@cnt)
END
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.