T-SQL Word Count Function 02 October 2013 Don-Rickman SQL Server - T-SQL (1) Function create function f_count_word_in_string (@field varchar(max), @word varchar(max)) returns int asbegin return (LEN(@field) - LEN(REPLACE(@field, @word,'')))/LEN(@word)end Test: select dbo.f_count_word_in_string('tester I want to test this, but how? oh tester tester', 'tester') Result: