Number of times a particular character appears in a string

后端 未结 10 2397
终归单人心
终归单人心 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:04

    try that :

    declare @t nvarchar(max)
    set @t='aaaa'
    
    select len(@t)-len(replace(@t,'a',''))
    

提交回复
热议问题