Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFQuery And S.Q.L. 2000 Server

Status
Not open for further replies.

velvetpuppet

Programmer
May 18, 2001
2
AE
I'm usin' Coldfusion & S.Q.L. 2000 Server database. I'm tryin' to match the exact word that a user enters with a field called Contents.

I tried the followin' CFQuery:
<CFQuery name=&quot;Q_Users&quot; datasource=&quot;DSN_IXS&quot;>
Select * From Users
Where User_ID In (#Category#)
And Contents = '#Keyword#'
</CFQuery>

But that CFQuery gave me an err msg sayin':
The text, ntext, and image data types cannot be compared or sorted, except when using NULL or LIKE operator.

I tried to replace the LIKE operator with the (=) operator as the followin':
<CFQuery name=&quot;Q_Users&quot; datasource=&quot;DSN_IXS&quot;>
Select * From Users
Where User_ID In (#Category#)
And Contents LIKE '#Keyword#'
</CFQuery>

This time I got no err msg, but I got no result even if the word is contained in the Contents field.

Do you suggest any solution to the problem?

With regards
 
Could it be possible you need to use &quot;&quot; instead of '' ?

So: And Contents LIKE &quot;#Keyword#&quot; ?

Regards
Bram
 
you need add % at both ends %#keyword#%
like this

<CFQuery name=&quot;Q_Users&quot; datasource=&quot;DSN_IXS&quot;>
Select * From Users
Where User_ID In (#Category#)
And Contents LIKE '%#Keyword#%'
</CFQuery>
 
you need to add % at both ends %#keyword#%
like this

<CFQuery name=&quot;Q_Users&quot; datasource=&quot;DSN_IXS&quot;>
Select * From Users
Where User_ID In (#Category#)
And Contents LIKE '%#Keyword#%'
</CFQuery>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top