Working on setting up a site search - (SQL Server).
Query below won't work as "feature_text" is a TEXT field
"mylst" will ALWAYS be a comma delimited list (cleaned of all unwanted
crap and common words)
<cfquery name="features">
SELECT
id_feature,
feature_headline,
feature_date,
year(feature_date) as theYEAR,
feature_text
FROM feature
WHERE feature_headline in
<cfqueryparam value="#mylst#" cfsqltype="CF_SQL_VARCHAR" list="yes" />
<cfloop list="#mylst#" index="i">
OR feature_text like
<cfqueryparam value="%#i#%" cfsqltype="CF_SQL_VARCHAR" />
</cfloop>
ORDER BY feature_date desc
</cfquery>
So, I can use CAST() to fix this and convert "feature_text" to varCHAR?
Something like:
<cfquery name="features">
SELECT
id_feature,
feature_headline,
feature_date,
year(feature_date) as theYEAR,
CAST (feature_text AS VARCHAR )
FROM feature
WHERE feature_headline in
<cfqueryparam value="#mylst#" cfsqltype="CF_SQL_VARCHAR" list="yes" />
<cfloop list="#mylst#" index="i">
OR CAST(feature_text as VARCHAR) like
<cfqueryparam value=""%#i#%"" cfsqltype="CF_SQL_VARCHAR" />
</cfloop>
ORDER BY feature_date desc
</cfquery>
But this gives me an odd "Incorrect syntax near '@P1'. " error....
Advise?
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5138 (20100522) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333914
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm