Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    1

    Unanswered: How to calculate number of occurances of a character in a string

    Is there a string function in T-sql which tells us that the number of occurances of a character in a string?

    eg. abracadabra

    no. of a's in the string : 5

    Any Help is appreciated.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    select len(@YourString)- len(replace(@YourString, 'a', ''))

    blindman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •