To find the count of a particular character inside a string

  • Dear All,

    I need to find the number of "~" present in a string. Is there any inbuilt function to do the same?? if not, can you please help me to achieving that?

    Pramod

  • Copied & adapted from http://www.sqlservercentral.com/Forums/Topic811310-338-1.aspx

    This is not my code, I learned something new here.

    SELECT (LEN(@string) - LEN(REPLACE(@string, '~', '')))

  • Duplicate post. Already answered this question in another post.

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply