CREATE FUNCTION [dbo].[com_CountString](@Input nVarChar(max),
@SearchString nVarChar(1000))
RETURNS INT
BEGIN
if @Input is null or @SearchString is null
return 0
DECLARE @InputLength INT, @SearchLength INT
SELECT @InputLength = LEN(@Input), @SearchLength = LEN(@SearchString)
IF @InputLength = 0 or @SearchLength = 0 or @SearchLength > @InputLength
return 0
RETURN (LEN(@input) - LEN(REPLACE(@input, @SearchString, ''))) / LEN(@SearchString)
END
I've spent time programming for the security industry, video games, and telephony. I live in New Zealand, and have a Bachelor of Computing and Mathematical Sciences specializing in Computer Technology, from the University of Waikato in Hamilton, New Zealand.