Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 52789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:57:43+00:00 2026-05-10T16:57:43+00:00

If I have a table field named ‘description’, what would be the SQL (using

  • 0

If I have a table field named ‘description’, what would be the SQL (using MS SQL) to get a list of records of all distinct words used in this field.

For example:

If the table contains the following for the ‘description’ field:

Record1 'The dog jumped over the fence.' Record2 'The giant tripped on the fence.' ... 

The SQL record output would be:

'The','giant','dog','jumped','tripped','on','over','fence' 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:57:43+00:00Added an answer on May 10, 2026 at 4:57 pm

    I do not think you can do this with a SELECT. The best chance is to write a user defined function that returns a table with all the words and then do SELECT DISTINCT on it.


    Disclaimer: Function dbo.Split is from http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

    CREATE TABLE test (     id int identity(1, 1) not null,     description varchar(50) not null )  INSERT INTO test VALUES('The dog jumped over the fence') INSERT INTO test VALUES('The giant tripped on the fence')  CREATE FUNCTION dbo.Split (     @RowData nvarchar(2000),     @SplitOn nvarchar(5) )   RETURNS @RtnValue table  (     Id int identity(1,1),     Data nvarchar(100) )  AS   BEGIN      Declare @Cnt int     Set @Cnt = 1      While (Charindex(@SplitOn,@RowData)>0)     Begin         Insert Into @RtnValue (data)         Select              Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))          Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))         Set @Cnt = @Cnt + 1     End      Insert Into @RtnValue (data)     Select Data = ltrim(rtrim(@RowData))      Return END  CREATE FUNCTION dbo.SplitAll(@SplitOn nvarchar(5)) RETURNS @RtnValue table (     Id int identity(1,1),     Data nvarchar(100) ) AS BEGIN DECLARE My_Cursor CURSOR FOR SELECT Description FROM dbo.test DECLARE @description varchar(50)  OPEN My_Cursor FETCH NEXT FROM My_Cursor INTO @description WHILE @@FETCH_STATUS = 0 BEGIN     INSERT INTO @RtnValue     SELECT Data FROM dbo.Split(@description, @SplitOn)    FETCH NEXT FROM My_Cursor INTO @description END CLOSE My_Cursor DEALLOCATE My_Cursor  RETURN  END  SELECT DISTINCT Data FROM dbo.SplitAll(N' ') 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer So, after a bit of digging through the Task Tracker… May 11, 2026 at 11:35 pm
  • Editorial Team
    Editorial Team added an answer use class="hilo": <generator class="hilo"> example: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NHibernate__MyClass" assembly="NHibernate__MyClass"> <class… May 11, 2026 at 11:35 pm
  • Editorial Team
    Editorial Team added an answer OK solved. I was passing DBNULL.Value as a parameter which… May 11, 2026 at 11:35 pm

Related Questions

If I have a table field named 'description', what would be the SQL (using
I need to query the database to get the column names , not to
I have a form with two fields with the name attribute of 'photo_title' and
Imagine I have a database with one table, this table has only one field
I have a View with a table representing an employee's timesheet. Days across the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.