Skip to main content
January 19, 2013
Question

cfqueryparam wildcards in tsql contains search

  • January 19, 2013
  • 1 reply
  • 806 views

I would like to implement cfqueryparam for my autocomplete function for a project I'm working on.

Currently the code I have is below and works by passing a argument variable into a tsql query.

SELECT

                users.user_id,

                users.first_name,

                users.last_name

FROM

                 users

WHERE

                CONTAINS(*, '"*#arguments.term#*"')

I would like to protect this by using cfqueryparam such as CONTAINS(*, <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.term#">) however the results are not as expected.

This topic has been closed for replies.

1 reply

Inspiring
January 19, 2013

This has asterisks around the variable.

CONTAINS(*, '"*#arguments.term#*"')

This does not

value="#arguments.term#"

January 19, 2013

I've tried to include the * in the cfqueryparam but it does not return the results I'm looking for with a autocomplete function.

CONTAINS(*, <cfqueryparam cfsqltype="cf_sql_varchar" value="*#arguments.term#*" />)

No errors are returned but now no results return. I have a list of names, if I pass just 'bo' into the query it should return records for bob, bobby, etc. Without cfqueryparam this was working great, but when I include this, no results are returned until I type out the full name 'bob' or 'bobby'. This function is a autocomplete search that checks several columns for partial strings.