Jaime Oro
Jaime Oro

Reputation: 10145

Seek row in SQL Server

How can I seek those rows which contain some text and get a mark depending on how many times this text was repeated?

Upvotes: 1

Views: 167

Answers (2)

TheCodeKing
TheCodeKing

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

Ming Yeh
Ming Yeh

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

Related Questions