Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-11-06 : 07:59:03
|
| Sandip writes "I am doing a Project for detection of advertisement in a Web page.For that I have used one column called ImageTextFor giving Training to my database I stored (say) 100000 records in ImageTextNow I want to First n Sequence of Text Which Comes Most TimesFor Exa:ImageText---------ABcABcdABABABABABABcdxyABABcdABcdABcdcdABHere,String No Of Times String Occurs------ ---------------AB 13cd 6ABc 6ABcd 3cdA 3......... ABc 1ABcd 1 ABABABABAB 1ABcdxyAB 1 ABcdABcdABcdcdAB 1That is i want to find within a string alsoFor First 3 Most Popular SequencesOutput------ABcdABcPlease ReplyIf you do not understand the question then send me mail" |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-06 : 08:28:08
|
| [code]CREATE FUNCTION dbo.fnFindWord( @SearchIn VARCHAR(8000), @SearchFor VARCHAR(8000))RETURNS INTASBEGIN DECLARE @Position INT, @Items INT WHILE @Position > 0 OR @Position IS NULL SELECT @Position = CHARINDEX(@SearchFor, @SearchIn, ISNULL(@Position, 0) + 1), @Items = CASE WHEN @Position > 0 THEN ISNULL(@Items, 0) + 1 ELSE @Items END RETURN ISNULL(@Items, 0)END[/code]Call with select dbo.fnFindWord('ababab', 'abab')Peter LarssonHelsingborg, Sweden |
 |
|
|
samuelclay
Yak Posting Veteran
71 Posts |
Posted - 2006-11-06 : 12:13:23
|
| Wow, what is supposed to be used to define a word (or sequence of text). It looks like the OP has it returning almost ever possible sequence 2 char or longer... but misses some... they have AB and ABc and cd, but doesnt have Bc or dA (but those might be included in the ...).So they want to go through 100000 records and count the number of every possible 2+ char sequence.. wow... Maybe more information would help here... |
 |
|
|
|
|
|
|
|