select dbo.getWordCount('we are the world , we are the children.', default)=========the result is 9 instead of 8.Because a space was accidentally input before the comma. But it would be great to filter out punctuations.

select dbo.getWordCount('we are the world , we are the children.', default)=========the result is 9 instead of 8.Because a space was accidentally input before the comma. But it would be great to filter out punctuations.

thanks.

You just used the function incorrectly.

You need to specify the comma as one of the delimeters, or modify it to include commas as a default delimiter.

declare @Delim nvarchar(256)
set @Delim = space(1)+char(9)+char(10)+','
select
[Word Count] =
dbo.getWordCount('we are the world , we are the children.',@Delim)

To Peso1) Your function doesn’t does the same job and better.See, please, attentively the description of my function.Your function works with delimiters ' .,'.2) Your function isn’t about 15 times faster than my function.Try it, please.