Реферат: Использование XML совместно с SQL
DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc ='
<root>
<Customer cid= "C1" city="Issaquah">
<name>Janine</name>
<Order oid="O1" date="1/20/1996" amount="3.5" />
<Order oid="O2" date="4/30/1997" amount="13.4">
Customer was very satisfied
</Order>
</Customer>
<Customer cid="C2" city="Oelde" >
<name>Ursula</name>
<Order oid="O4" date="1/20/1996" amount="10000">Happy Customer.</Order>
<Order oid="O3" date="7/14/1999" amount="100"
note="Wrap it blue white red">
Sad Customer.
<Urgency>Important</Urgency>
</Order>
</Customer>
</root>'
-- Создание внутреннего представления XML-документа.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
SELECT *
FROM OPENXML (@idoc, '/root/Customer', 2) WITH
(
cid char(5) '@cid',
[name] varchar(20),
oid char(5) 'Order/@oid',