The data types text and varchar are incompatible in the equal to operator


select * from notes where comment = 'Status change gg toyy'

the stupid comment field in this system is type text in SQL so how do I get around this error:

The data types text and varchar are incompatible in the equal to operator.
LVL 1
dba123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
you need to use 'Contains '
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please try this:
select * from notes where substring(comment, 1, 500) = 'Status change gg toyy'

if you don't need to store strings longer than 8000 characters in the notes field, change it to varchar(8000)  if you are using sql server 2000, with sql server 2005 use varchar(max) instead
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>you need to use 'Contains '
that is only working if the field "notes" has been added into a full-text search catalog !
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

dba123Author Commented:
select * from notes where comment CONTAINS 'Status change gg toyy'
0
dba123Author Commented:
I'd love to get rid of the text field Angel but this is a stupid s***ty ass 3rd party piece of S**t
0
Aneesh RetnakaranDatabase AdministratorCommented:

SELECT *
FROM notes
WHERE CONTAINS(ProductName, '"Status change gg toyy" ')
0
dba123Author Commented:
It's amazing how these 3rd party companies out there today (even IBM with their s***ty ass ClearQuest) can charge a ton for such a S**ty application design.
0
dba123Author Commented:
time for me to go into business??  anyone want to hop aboard...jk
0
Aneesh RetnakaranDatabase AdministratorCommented:
As angel suggested , you should enable full text indexing on 'Comments'
0
dba123Author Commented:
yea, well I don't know if that will break the system for this API that I don't work with....I could enable that but if our network guys start to get calls on slow performance then guess who they come to first!
0
dba123Author Commented:
sorry for all the swearing, I just can't believe what I see in 3rd party apps these day...disgusting.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if you don't dare implementing the full-text search on it (btw, I doubt this will not be working anyhow for exact match), you should try out my very first comment
0
dba123Author Commented:
Thanks much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.