Number of times a particular character appears in a string

后端 未结 10 2442
终归单人心
终归单人心 2020-11-27 16:41

Is there MS SQL Server function that counts the number of times a particular character appears in a string?

10条回答
  •  天命终不由人
    2020-11-27 17:07

    You can do that using replace and len.

    Count number of x characters in str:

    len(str) - len(replace(str, 'x', ''))
    

提交回复
热议问题