The first way that comes to mind is to do it indirectly by replacing the comma with an empty string and comparing the lengths
Declare @string varchar(1000)
Set @string = 'a,b,c,d'
select len(@string) - len(replace(@string, ',', ''))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…