Reputation: 10145
How can I seek those rows which contain some text and get a mark depending on how many times this text was repeated?
like %criteria%
and then count how many times the text is repeated on each record but it doesn't seem very efficient.Upvotes: 1
Views: 167
Reputation: 19240
If I understand what you are trying to do, I suggest you use a text to word list function. There's a few examples here. If using full-text indexing, you could even use CONTAINSTABLE. You can then join to this table value function and aggregate the count.
Select t.*,
(Select count(w.*)
From dbo.getWordList(t.text) w
Where w.word like '%criteria%') as Count
From MyTable t
Where t.text like '%criteria%'
Alternatively you could just solve the entire problem in a CLR function.
Upvotes: 1
Reputation: 1
If you wanna get the appearance times of string in a single SQL Server data record, the RegEx would be more appropriate.
Upvotes: 0