0

How should I be able to count the word "asdf" in the variable aaa with value "asdf_dd_adf34asdf_sdf"?

DECLARE @aaa varchar;

SET @aaa = 'asdf_dd_adf34asdf_sdf';
4

1 回答 1

3

如果删除单词的出现次数,然后除以单词的长度,请计算有多少字符消失:

(len(aaa) - len(replace(aaa, 'asdf', ''))) / len('asdf')
于 2012-04-07T07:40:24.423 回答