XML Management (Beginner)

Feb 19 2008 7:10 AM
Hello everyone. I just am a beginner and am learning XML maipulation. Now i tried this and it doesn't work for me. I can't figure out what the error is. The error it shows is



The XML parse error 0xc00ce505 occurred on line number 4, near the XML text "        <Order OrderID = "1001" Cu".
Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1
The error description is 'A name contained an invalid character.'.
Msg 208, Level 16, State 1, Line 23
Invalid object name 'CustomerDetails'.



Here's the statements that i have written.


create database Abhishek
use Abhishek

DECLARE @Doc int
DECLARE @XMLDoc nvarchar (100)
SET @XMLDoc = N'
<ROOT>
    <Customer CustomerID = "JH01" ContactName = "John Henriot">
        <Order OrderID = "1001" CustomerID = "JH01" OrderDate = "2006-07-04T00:00:00">
            <OrderDetail ProductID = "11" Quantity = "12"/>
            <OrderDetail ProductID = "22" Quantity = "10"/>
        </Order>
    </Customer>

    <Customer CustomerID = "SG01" ContactName = "Steve Gonzlez">
        <Order OrderID = "1002" CustomerID = "SG01" OrderDate = "2006-08-16T00:00:00">
            <OrderDetail ProductID = "32" Quantity = "3"/>
        </Order>
    </Customer>
</ROOT>'

exec sp_xml_preparedocument @Doc OUTPUT, @XMLDoc

INSERT INTO CustomerDetails
SELECT * FROM openxml(@Doc,'/ROOT/Customer',1) WITH (CustomerID varchar(10), ContactName varchar(20))


I'd really appreciate your help :)


EDIT  : OMG i caught my fault ! I declared the DECLARE @XMLDoc nvarchar (100) toooooooo small !!! lmao