Avatar of ethar turky
ethar turky
Flag for Saudi Arabia asked on

Get Repeated words or phases

Dear all,
I need to get repeated phases ( or words ) on huge nuber of rows ( CompanyDecision ntext )
and inserted in another table:

FamousPhases, Counts


Thanks,
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
TempDBA

8/22/2022 - Mon
TempDBA

Can you explain with examples? it will be more helpful for the experts here to give the precise answer.

Moreover, what I have got from the question is you want to give the count of the repeated words from a table to other.
So,

insert into <destinationTable> (word,Repeated)
select word, count(*) as count
from sourceTable
group by word
having count(*) > 1
Patrick Matthews

Also, if you are working in SQL 2008, you should consider using nvarchar(max) instead of ntext.  nvarchar(max) will allow the same long strings as ntext, but is much more functional than ntext.
ethar turky

ASKER
yes, I am using nvarchar(max).
in CompanyDecision there is phrases,
I need to collect famous phrases or piece of text and how many its repeated along the DB.

for example:
Row#1 Well, she has long, black hair and blue eyes with funny smile at Morning .
Row#2 He's funny, cute and really rich.
Row#3 He reminds me with funy smile of that guy with long, black hair on the Morning Show.

The result :
has long, black hair   :   2
funy smile  : 2
funny : 3
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Anthony Perkins

This is best handled with something like .NET.  T-SQL is not the right tool for this.
IrogSinta

There seem to be other variables that you haven't mentioned.  How would you handle words like "the", "an", "a" for instance?  Do you want to count those too?

In your example for has long, black hair having a count of 2, it really should be

has: 1
long: 2
long, black: 2
long, black hair: 2
with: 2      (one from with funny smile and the other from with long, black hair)

Is the above what you were after?
ethar turky

ASKER
I need to count all words but not "an" or "a" or "the"

I am ok with your result.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
IrogSinta

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
TempDBA

This will be best taken care by content search tool like ISYS and SOLR