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?
- I have SQL Server CTP3 installed but I don't know where to start
- Maybe I can use
like %criteria%
and then count how many times the 开发者_JAVA百科text is repeated on each record but it doesn't seem very efficient. - It would be great if there was any routine on SQL Server for doing it
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.
If you wanna get the appearance times of string in a single SQL Server data record, the RegEx would be more appropriate.
精彩评论