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 8895523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:48:10+00:00 2026-06-14T23:48:10+00:00

I have a user table with a single column for a person’s name: CREATE

  • 0

I have a user table with a single column for a person’s name:

CREATE TABLE [dbo].[Users]
(
    Id bigint NOT NULL,
    Name nvarchar(80) NOT NULL,
    PRIMARY KEY CLUSTERED (Id ASC)
)

The Name column can contain either a full name or just the first name or anything really (separated by spaces). In order to implement a search on Name, I would like to utilize SQL’s full-text search, but not sure if it’s suitable for searching names/nicknames and not actual words. Also the question is – which language do I choose when creating the FT index on Name?

Any other considerations?

Thank you.

  • 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-06-14T23:48:12+00:00Added an answer on June 14, 2026 at 11:48 pm

    It seems that if you want to search multi-part names, full-text search is the easiest and most appropriate approach (please correct me if I’m wrong). The other alternative being LIKE '%query%', however it has too many disadvantages:

    • Terrible performance, since it does index scan
    • Order of terms matters, e.g. – searching for “John Smith” and “Smith John” will return different results.
    • It disregards word boundaries, e.g. – searching for “Ann” will also retrieve “Joanna” and “Danny”, which aren’t useful matches.

    So I went ahead and implemented a full-text search. My queries look something like this:

    SELECT * FROM Users WHERE CONTAINS(Name, '"John*"')
    

    The only slight difficulty is that I had to convert user query (John) into a CONTAINS-friendly query (“John*”). To do that, I implemented this method in my UserRepository:

    /// <summary>
    /// Converts user-entered search query into a query that can be consumed by CONTAINS keyword of SQL Server.
    /// </summary>
    /// <example>If query is "John S Ju", the result will be "\"John*\" AND \"S*\" AND \"Ju*\"".</example>
    /// <param name="query">Query entered by user.</param>
    /// <returns>String instance.</returns>
    public static string GetContainsQuery(string query)
    {
        string containsQuery = string.Empty;
    
        var terms = query.Split(new[] { ' ' }, StringSplitOptions.None);
    
        if (terms.Length > 1)
        {
            for (int i = 0; i < terms.Length; i++)
            {
                string term = terms[i].Trim();
    
                // Add wildcard term, e.g. - "term*". The reason to add wildcard is because we want
                // to allow search by partially entered name parts (partially entered first name and/or
                // partially entered last name, etc).
                containsQuery += "\"" + term + "*\"";
    
                // If it's not the last term.
                if (i < terms.Length - 1)
                {
                    // We want all terms inside user query to match.
                    containsQuery += " AND ";
                }
            }
    
            containsQuery = containsQuery.Trim();
        }
        else
        {
            containsQuery = "\"" + query + "*\"";
        }
    
        return containsQuery;
    }
    

    Hope this helps anyone stumbling into the same issue.

    PS – I wrote a blogpost documenting this.

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

Sidebar

Related Questions

I have a single table containing many users. In that table I have column
I have a table defined like this: CREATE TABLE mytable (id INT NOT NULL
i have a table with single row (textfield) and Add Row button, when user
I have a single product table with multiple fields which contain user evaluations of
I have a user table with a level column. The level column is numeric
I have a user table 'users' that has fields like: id first_name last_name ...
Currently I have a User table that has a toys_owned column that is an
i have an orders table that has a userID column i have a user
I have to implemene Single Table Inheritance for a class Person who can be
I have a need to create a user table type. My preference is to

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.