Ryan Rinaldi

.net development served with a slice of sarcasm
  • rss
  • About Me
  • Blog
  • Contact

The function I promised

Ryan Rinaldi 7/18/2008 6:55:07 AM

Well, I really didn't promise it but I had some free time at work waiting for Visual Studio .NET to repair itself. (Why does uninstalling Visual Studio .NET 2002 kill the file associations for Visual Studio .NET 2003?  Can someone explain that one?) Anyway, without further ado I give you the function:

CREATE FUNCTION dbo.fnInStringCount(
 @string varchar(1000),
 @searchstring varchar(100)
)
RETURNS int
AS
BEGIN

 DECLARE @temp varchar(1000)
 SET @temp = REPLACE(@string, @searchstring, '')

 RETURN (LEN(@string) - LEN(@temp)) / LEN(@searchstring)
END

SELECT dbo.fnInStringCount('Ryan Rinaldi', 'R')

I ask only one thing.  That if you find this useful, let me know.  :)

Comments
No Comments
Tags
blog

Leave a Comment

  • My Tweets

    • Looking at our options to move to TFS 2010 from 08 and change process template: just as painful to migrate off of TFS. sigh.
    • RT @Snywhip: I'm very proud of Spain and it's banning of the bull fights starting in 2012. Finally ;)
    • RT @adamtybor: @sergiopereira happy birthday!
    • Follow Me on Twitter
Powered by Graffiti CMS
  • Content © Ryan Rinaldi 2010
  • design by jide
  • Theme converted to GraffitiCMS by Adonis Bitar