XML Data Type error
RobertKaucher
Member Posts: 4,299 ■■■■■■■■■■
I am attempting the following query:
---
DECLARE @MyXML AS XML(MyXMLSchema)
SET @MyXML '<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<item>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</quantity>
<price>9.90</price>
</item>
</shiporder>'
INSERT INTO OrderDetails values('John', 'Smith', '513.555.1212', @MyXML)
---
I get the following error:
---
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>40'.
---
Any ideas?
---
DECLARE @MyXML AS XML(MyXMLSchema)
SET @MyXML '<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<item>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</quantity>
<price>9.90</price>
</item>
</shiporder>'
INSERT INTO OrderDetails values('John', 'Smith', '513.555.1212', @MyXML)
---
I get the following error:
---
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>40'.
---
Any ideas?
Comments
-
brad- Member Posts: 1,218Robert,
IDK if you've tried the msdn forums, but they help sometimes.
http://forums.microsoft.com/MSDN/default.aspx?forumgroupid=19&siteid=1 -
RobertKaucher Member Posts: 4,299 ■■■■■■■■■■Sorry for the delay, Brad. I like to post here first just to try to get this forum going. MAkes sense since I take a week to reply to my own replies! I actually figured it out. The schema I created seems to have been incorrect.