Database Reference
In-Depth Information
</states>
'
)
2.
Run the two
INSERT
statements, and then display the table with
select * from
xmltest
. You see the two rows displayed. Click the
xdoc
column in the first row,
and you should see the XML shown in Figure 7-5.
Figure 7-5.
Viewing an XML document
How It Works
This works like all
INSERT
s work. You simply provide the primary keys as integers and the XML
documents as strings. The query works just as expected too.
Summary
This chapter covered the fundamentals of XML that every C# programmer needs to know. It also showed
you how to use the most frequently used T-SQL features for extracting XML from tables and querying
XML documents like tables. Finally, I discussed the
xml
data type and gave you some practice using it.
How much more you need to know about XML or T-SQL and ADO.NET facilities for using XML
documents depends on what you need to do. For many, this chapter may be all you ever really need to
know about XML. For those who do more sophisticated XML processing, you now have a strong
foundation for experimenting on your own. In the next chapter, you will learn about transactions.