[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
-- first up lets build a test table and some dummy data so we can play with our query
if object_id('tempdb..#my_table','U') is not null drop table #my_table
create table #my_table (id int identity, comments varchar(200))
insert #my_table (comments)
select 'This is title one.' as comments
select 'This is title two.'
select 'This ! is yet another title two.'
select 'And what about puntuation?'
select 'Or maybe "quotes"'
-- now we have some test data to play with, lets see what kind of query we can come up with...
;with words_cte as
select rtrim(ltrim(substring(comments,n,charindex(' ',comments+' ',n+1)-n))) as The_Word
from ( select replace(replace(replace(replace(comments,'"',' '),'!',' '),'?',' '),'.',' ') as comments from #my_table ) srce
cross join (select number n from master..spt_values where type = 'p') numbers
where substring(' '+comments,n,1) = ' '
and n <= len(comments+' ')
select the_word --, count(*) as occurances
where len(the_word) > 0 -- eliminate noise words as much as possible so make it 1,2 or 3 instead of zero.
group by the_word
-- to test the above query against your own test data,
-- first replace the column "comments" with the real column name,
-- and the table "#my_table" with your table name
Open in new window
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.
select distinct value
from (select f.value from yourtable t cross apply dbo.ParmsToList(t.your_column_name, ' ') f) sq
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.