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

  • SEARCH
  • Home
  • 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 6644607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:11:12+00:00 2026-05-26T00:11:12+00:00

In our case, we’re restricted to SQL Server 2000. Say we have a table

  • 0

In our case, we’re restricted to SQL Server 2000.

Say we have a table “Articles” with a field “ArticleText”. How do we search a string consisted of many words, and return the number of found occurrences.

An example of a search string: John is a nice boy (so it contains 5 words)

ID  ArticleText                         Result
1   John is going to learn              2
2   John is doing his homework nice-ly  3
3   John is a nice boy                  5

Up to now I’ve found a split function
for sql server 2000 to delimit the search string. Now I’m trying to iterate through the records and display the count of found words in one field, but I got stuck. Any help?

  • 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. Editorial Team
    Editorial Team
    2026-05-26T00:11:13+00:00Added an answer on May 26, 2026 at 12:11 am

    SQL Server 2000 solution

    New idea. Try splitting the search string first into 1 temp table. Then joining back to the articles using wild cards.

    DECLARE @Search nvarchar(200); 
    SET @Search = 'John is a nice boy'; 
    IF NOT OBJECT_ID('tempdb..#S') IS NULL
    DROP TABLE #S; 
    
    SELECT * 
    INTO #S 
    FROM dbo.Split(@Search, ' '); 
    
    SELECT a.ID, a.ArticleText, COUNT(*) as [Result] 
    FROM #S as s 
    JOIN Articles as a on a.ArticleText like s.Data + ' %' 
    OR a.ArticleText like '% ' + s.Data + '%' 
    GROUP BY a.ID, a.ArticleText
    

    I tested this on SQL Server 2008 R2 with 2000 compatibility mode.

    The 2 join conditions ensure that it matches the first word or any beginning of words (to get ‘nice-‘ ).
    You should tweak this to your requirements and consider replace functions for the hyphen and other punctuation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MaskedTextBox control that, in our case, is collecting social insurance (tax)
We were previously using a non-search engine friendly custom CMS for our case record
We develop system with client-server architecture. But in our case client must communicate with
In our SQL Server 2005 database (tested using Management Studio with DBCC FREEPROCCACHE and
In our case we have some business logic that looks into several tables in
I want to learn the answer for different DB engines but in our case;
Our usage case is a database responsible for accounts, sessions, licenses, etc. — it
In our FB configuration a new case is category = Bug per default. I
Sometimes in case of a bug in our code, we usually ask the end
Let me describe a simple use-case: Running all tests in our project may take

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.