Gets an implementation of the number of occurrences of a string in a long string in SQL
- 2020-05-27 07:20:01
Gets the number of occurrences of a string in a long string in SQL
Let's say I have a string:
I want to know how many times the '-' occurs, which can be done in the following way, without the need for complex 1-by-1 character analysis.
declare @a varchar(100)
If you want to determine how many letters c are in the b field in a, you can write it like this
select len(replace(b,'c','--')) -len (b) from a, of course, the function len may vary from database to database