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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:53:05+00:00 2026-06-02T23:53:05+00:00

I’m trying to achieve something that Im not sure how to do it. I’m

  • 0

I’m trying to achieve something that Im not sure how to do it. I’m working on a website based on ASP Classic and SQL 2008, IIS7. In search page I have option to have couple value per query like default.asp?q=one|two|three&q2=four|five|six .
What Im trying to do is to use wildcard in case my queries dont have value and have ability to search couple word in one column at the same time in case my query has couple value. Here are what I want to do:

  1. If query has value then go fine that in database (Which is pretty simple)
  2. If query has couple value separated with “|” sign then split them and search for all of them.
  3. If query does not have value at all, then use wildcard and do not search
    for anything.

So to achieve this I’ve tried couple thing but didn’t get any success. Here is the example of my code.

One ———–

@style nVarchar(150) = ''
Select * FROM mytable WHERE CONTAINS(style, @style) AND ...

I can manage to split the query to something like '"* value1 *" OR "* value2 *"' to get the best result out of CONTAINS but This one is working if “style” has value. If style does not have value there is no wildcard so I can retrive all data without filtering down the database.

Two —————

@style nVarchar(150) = ''
Select * FROM mytable WHERE style LIKE '%' + @style + '%' AND ...

With LIKE clause I can use wildcard like '%' in case style does not have any value but I cannot search couple value in the same column.
So, keep in mind I’m using “Stored Procedure” since this is kind of complex and I need to use this in couple places. I will have have 10-12 query for this search.
Any Idea will help me to get this going.

  • 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-02T23:53:07+00:00Added an answer on June 2, 2026 at 11:53 pm

    I understand your problem is with values separated by “|”. In SQL 2008 you can use Xml functions to transform the string into a table and query it against your base table:

    DECLARE @style VARCHAR(MAX) = 'value1|value2|value3'
    DECLARE @v XML 
    SET @v = '<r><n>' + REPLACE(@style, '|', '</n><n>') + '</n></r>'
    
    SELECT * FROM mytable
    OUTER APPLY 
    (
        SELECT c.value('text()[1]', 'varchar(50)') AS v FROM @v.nodes('//n') AS t(c)
    ) t
    WHERE style LIKE '%' + t.v + '%'
    

    Does it help?

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.