Hi
There is a lot of information about using XML in SQL Server 2008 on MSDN. The section for using it in tables is at
http://msdn.microsoft.com/en-us/library/bb510446.aspx but admittedly it is not all clear.
Here is a simple example for creating a table with an untyped (xml is not validated) xml column, then inserting and selecting the data:
sql Code:
-- create the table - note the XML datatype
CREATE TABLE XmlSample (
ID INT PRIMARY KEY,
SampleData XML NOT NULL
);
-- add a row - xml is added the same way as a normal VARCHAR etc.
INSERT INTO XmlSample (ID, SampleData) VALUES (1, '
<Root>
<Foo name="bob">
<Bar />
</Foo>
<Foo name="dave">
<Bar />
</Foo>
</Root>
');
-- get data back - SSMS lets you click the XML cell and show the full document
SELECT * FROM XmlSample;
(I am using SQL Server 2005, but I can't see any changes required for 2008. Please correct me if I'm wrong)
HTH
Phil