title: XML Data Column in SQL Server
body: <p>Using SQL Server 2008 R2</p>
  
  <p>I'd like to create a table with the following columns</p>
  
  <pre><code>[id] INT IDENTITY(1,1) NOT NULL,
  [user_id] INT NOT NULL,
  [date] DATE NOT NULL,
  [timestamp] DATETIME NOT NULL,
  [xml_data] XML NOT NULL
  </code></pre>
  
  <p>with the primary key on the identity column and a non-clustered index on user_id and date that covers xml_data and timestamp.</p>
  
  <p>However, I notice that I can't add xml_data to the INCLUDE statement in the index.  Sad face, since that's going to result in an RID lookup when a user searches on user_id and date.</p>
  
  <p><strong>What's the best way to store xml data that will be queried?</strong>  </p>
  
  <p>I figure my choices are</p>
  
  <ol>
  <li>Stick with xml and have well-formatted data but take the query hit</li>
  <li>Use a VARCHAR(MAX) with unknown pros/cons</li>
  <li>Use a VARBINARY(MAX) with unknown pros/cons</li>
  </ol>
  
  <p>Note: I doubt I'll be able to restrict the length of the string to even something like 8000.</p>