XML parsing error: 'A string literal was expected' when inserting values into table

Posted by Christian on Stack Overflow See other posts from Stack Overflow or by Christian
Published on 2012-11-04T22:50:30Z Indexed on 2012/11/04 23:00 UTC
Read the original article Hit count: 1501

Filed under:
|
|
|
|

In Microsoft Sequel Server 2008 I am attempting to insert values into an sql table with the columns type_id of datatype int and xml_info of datatype XML. I am using the following query:

INSERT INTO tbl_applied_devices ([type_id],[xml_info])
VALUES (1,'<Profile ID=99><Server><ID>BC4A18CA-AFB5-4268-BDA9-C990DAFE7783</ID>  <Name>localhost</Name><Services></Services></Server></Profile>')

But I keep getting this error:

Msg 9413, Level 16, State 1, Line 4
XML parsing: line 1, character 13, A string literal was expected  

What am I doing incorrectly? Thank you for the help.

EDIT: I found that the source of the error is the xml element's ID attribute, where seems to be what is causing the error. How can I correctly insert xml with an attribute ? Do I need to somehow escape one of the characters?

© Stack Overflow or respective owner

Related posts about sql

Related posts about Xml