Experts Exchange connects you with the people and services you need so you can get back to work.
-- 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
Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.
select distinct value
from (select f.value from yourtable t cross apply dbo.ParmsToList(t.your_column_name, ' ') f) sq
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.