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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:12:55+00:00 2026-05-16T15:12:55+00:00

Need to write a SQL query to search special character in a column. Text

  • 0

Need to write a SQL query to search special character in a column. Text needed to search is ‘R&D’ but issue is that SQL server 2005 is taking it as a logical operator.

  • 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-16T15:12:56+00:00Added an answer on May 16, 2026 at 3:12 pm

    I guess you are using parameters, correct?
    Because if you do NOT use parameters, it works (see the other answers).

    What doesn’t work is this:

    declare @tmp nvarchar(20)
    set @tmp = 'R&D'
    
    select * from MyTable where MyColumn = @tmp
    

    The only way that I found to make it work with parameters is doing it like this:

    declare @tmp nvarchar(20)
    set @tmp = 'R&D'
    
    select * from MyTable where MyColumn like '%' + @tmp + '%'
    

    EDIT:

    First of all, I need to know if you’re using parameters or not.

    If not, I don’t understand the problem at all.
    One of these will work (with or without LIKE):

    select * from MyTable where MyColumn = 'R&D'
    select * from MyTable where MyColumn like '%R&D%'
    

    If you do work with parameters, my above solution ( … like ‘%’ + @tmp + ‘%’) is the only one that I know of.


    EDIT 2

    Now that I know that the data type is “text”:
    The problem is that you can only search text with LIKE (not with ‘=’) and you can’t index a text column to increase speed.
    The text data type is deprecated, so you should change it into varchar(max) anyway.
    And varchar(max) doesn’t have the limitations that text has: you can search it with ‘=’ and you can index it.

    So that would be the correct solution: change it from text to varchar(max) and everything will work!

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

Sidebar

Related Questions

I need to write a query on SQL server to get the list of
I need help with how to write a SQL Server 2005 query to handle
Ok this is driving me nuts, I need to write an SQL query that
I need to write a SQL Query for Advance search form shown as Image
I need to write a query that will perform a keyword search on a
I need to write a SQL query that will generate a list of valid
I need to write some sql that will allow me to query all objects
I need to write a SQL query which will get me those rows from
I have a table of products, and I need to write an SQL query
Since i'm a poor sql developer, i need support to write a sql query

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.