Hello Partners, somebody know if exists some function for counting the number of times that a character is inside of a string?

  • Oh...well....keep up the good work! 

    Signature is NULL

  • A late thought...

     

    The function idea has one "hole" - if an empty or null varchar is passed.

    imho, use:

     

    RETURN(SELECT ISNULL((DATALENGTH(@String) - DATALENGTH(REPLACE(@String, @Search, '')))

             / NULLIF(DATALENGTH(@Search), 0), 0))

     

    I've been "bit" by that before.

     

Viewing 2 posts - 16 through 16 (of 16 total)

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