cfqueryparam, cfsqltype, Lists, and You

June 3, 2026    

Something that might trip up ColdFusion beginners is how to choose which cfsqltype to give to cfqueryparam when you're using a list of IDs. For example:

local.ids = "1,2,3,4,5,6";

queryExecute(
  "
    SELECT Name
    FROM myTable
    WHERE ID IN (:ids)
  ",
  {
    ids: {
      value: local.ids
      cfsqltype: "???"
    }
  }
);

This is a trivial example, but it begs the question for some: in ColdFusion, a list is a string, even when it's a list of integers. So, should I choose "varchar" for the sql type, or should I choose "integer"?

The answer is simple - always prefer the sql type of each item in the list. In the example above, we have a list of integers, so the appropriate cfsqltype would be "integer". Be sure to specify list: true as well so ColdFusion knows it's a list and treats it appropriately.

Here's a better version of the code from above.

local.ids = "1,2,3,4,5,6";

queryExecute(
  "
    SELECT Name
    FROM myTable
    WHERE ID IN (:ids)
  ",
  {
    ids: {
      value: local.ids,
      cfsqltype: "integer",
      list: true
    }
  }
);

The same guidance applies to tag-based queries as well:

<cfqueryparam value="#local.ids#" cfsqltype="integer" list="true" />