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
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
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"
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