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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:32:22+00:00 2026-05-25T19:32:22+00:00

I have not worked much with TSQL or the full-text search feature of SQL

  • 0

I have not worked much with TSQL or the full-text search feature of SQL Server so bear with me.

I have a table nvarchar column (Col) like this:

       Col  ... more columns
Row 1: '1'
Row 2: '1|2'
Row 3: '2|40'

I want to do a search to match similar users. So if I have a user that has a Col value of ‘1’ I would expect the search to return the first two rows. If I had a user with a Col value of ‘1|2’ I would expect to get Row 2 returned first and then Row 1. If I try to match users with a Col value of ‘4’ I wouldn’t get any results. I thought of doing a ‘contains’ by splitting the value I am using to query but it wouldn’t work since ‘2|40’ contains 4…

I looked up the documentation on using the ‘FREETEXT’ keyword but I don’t think that would work for me since I essentially need to break up the Col values into words using the ‘|’ as a break.

Thanks,
John

  • 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-25T19:32:22+00:00Added an answer on May 25, 2026 at 7:32 pm

    You should not store values like ‘1|2’ in a field to store 2 values. If you have a maximum of 2 values, you should use 2 fields to store them. If you can have 0-many values, you should store them in a new table with a foreign key pointing to the primary key of your table..

    If you only have max 2 values in your table. You can find your data like this:

    DECLARE @s VARCHAR(3) = '1'
    
    SELECT * 
    FROM <table> 
    WHERE @s IN( 
        PARSENAME(REPLACE(col, '|', '.'), 1),  
        PARSENAME(REPLACE(col, '|', '.'), 2) 
        --,PARSENAME(REPLACE(col, '|', '.'), 3) -- if col can contain 3 
        --,PARSENAME(REPLACE(col, '|', '.'), 4) -- or 4 values this can be used
      )
    

    Parsename can handle max 4 values. If ‘col’ can contain more than 4 values use this

    DECLARE @s VARCHAR(3) = '1'
    
    SELECT * 
    FROM <table> 
    WHERE '|' + col + '|' like '%|' + @s + '|%'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have not worked with arrays much in PHP. I have a table of
I have not worked with parameters in ADO.Net very much. I'm writing a custom
I am working on a Java project for class and have not worked much
I have not worked so much with files: I am wondering about possible issues
I have not worked with DOS much as there were always shell scripting in
I have not worked with XML much so this may be a basic question
I have not worked much on virtual machines and I need some help in
I'm ashamed to say it, but I have to. I have not worked with
So I've never worked with stored procedures and have not a whole lot of
I have worked on iPhone application but not aware of the formalities to submit

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.