This function will return the number of occurrences of one string within another string. I was looking for something like this recently, and the only thing I could find was needlessly complicated. Don't forget, when calling a scalar function, you must qualify with username like this:
Select dbo.StringCount('Hi There','e')
This function may be a little too simple for your needs, but, you can modify and use any way you like. You could also easily create a procedure, with or without output parameter, with the same code. Enjoy.
A short but interesting article, the author has figured out a way to create a PDF from a stored procedure without using a third party library.