Storing arbitrary form data in SQL as an XML blob I am currently storing form data in an XML format:

&lt;cfsavecontent variable="myFormData"&gt;
&lt;cfoutput&gt;
  &lt;ul class="xoxo"&gt;
  &lt;cfloop list="#form.fieldnames#" index="item"&gt;
    &lt;cfloop list="#form[item]#" index="eachItem"&gt;
  &lt;li&gt;&lt;b&gt;#xmlformat(item)#&lt;/b&gt; &lt;var&gt;#xmlformat(eachItem)#&lt;/var&gt;      
    &lt;/cfloop&gt;
  &lt;/cfloop&gt;
 &lt;/ul&gt;
&lt;cfoutput&gt;
&lt;/cfsavecontent&gt;


Then do a single insert:

&lt;cfquery&gt;
   INSERT INTO table (formData)
   VALUES (&lt;cfqueryparam value="#myFormData#" cfsqltype="cf_sql_varchar"&gt;)
&lt;/cfquery&gt;


When I pull the data out, I can:

&lt;cfquery name="qryData"&gt;
   SELECT formData
   FROM table
   WHERE ID = &lt;cfqueryparam value="#ID#" cfsqltype="cf_sql_integer"&gt;
&lt;/cfquery&gt;

&lt;cfoutput query="qryData"&gt;#formData#&lt;/cfoutput&gt;


OR

&lt;cfquery name="qryData"&gt;
   SELECT li.value('(b/text())[1]', 'varchar(50)') AS Item, 
      li.value('(var/text())[1]', 'varchar(50)')   AS Value
   FROM table
   CROSS APPLY XmlData.nodes('/ul/li') AS ul(li)
   WHERE ID = &lt;cfqueryparam value="#ID#" cfsqltype="cf_sql_integer"&gt;
&lt;/cfquery&gt;

&lt;cfoutput query="qryData"&gt;#Item# #Value#&lt;/cfoutput&gt;


Some developers have concerns about storing the data in this format. Is this the best way to store arbitrary form data?
Well, it depends what you want to do with this data. If you ever want to query individual field names or debug an issue with a field you will have a hard time extracting this kind of information out of an XML blob.

Potential pitfall: According to the coldfusion docs, CF_SQL_VARCHAR maps to varchar columns on MSSQL. You need to make sure that the column is varchar(max) as XML can get pretty verbose and any character limit might get hit.

On how to better store the data this is hard to say. From your example it looks like a form has fields and each field could have multiple values. This looks like a classic 1:n relationship to me:

Form table:

FormID | Name | Description | ...


Field Name table:

FieldID | FormID | Name


Field Value table:

ValueID | FieldID | Value