Store XML in SQL database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have an XML document that I want to store in the SQL Server/Exprss
database. The database table has a column of type XML.

I saw examples how to read XML column, but I haven't seen any ADO.NET way
how to store XML data in the database.

Could anybody give me a hint?

Thanks for help,
Lubomir
 
Hi Lubomir,

XML type is essentially a string so following statement is valid.

INSERT INTO Customer VALUES (1,'Lubomir',
'<order>
<item>
<id>20</id>
<name>Widgets</name>
<units>3</units>
</item>
</order>')

Note: if you are using generic accessor methods of SqlReader, it will
always return .NET String class for XML type columns.

Regards
JIGNESH
 
Hi Jignesh,

Thanks.

Regards,
Lubomir


JIGNESH said:
Hi Lubomir,

XML type is essentially a string so following statement is valid.

INSERT INTO Customer VALUES (1,'Lubomir',
'<order>
<item>
<id>20</id>
<name>Widgets</name>
<units>3</units>
</item>
</order>')

Note: if you are using generic accessor methods of SqlReader, it will
always return .NET String class for XML type columns.

Regards
JIGNESH
 
Back
Top