Using SQL Server 2008 R2
I'd like to create a table with the following columns
[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
with the primary key on the identity column and a non-clustered index on user_id and date that covers xml_data and timestamp.
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.
What's the best way to store xml data that will be queried?
I figure my choices are
- Stick with xml and have well-formatted data but take the query hit
- Use a VARCHAR(MAX) with unknown pros/cons
- Use a VARBINARY(MAX) with unknown pros/cons
Note: I doubt I'll be able to restrict the length of the string to even something like 8000.