December 2013
Intermediate to advanced
1872 pages
153h 31m
English
In this section, you define a simple XML schema, add it to a new schema collection stored on the server, and create a table where you can store instances of this schema (see Figure 49.1). You also add a check constraint to ensure that the value of the ProductId attribute of the XML’s root node matches the value of the ProductId column, using the xml data type value() method (discussed later in this chapter, in the section, “The Built-in xml Data Type Methods”). The foreign key constraint you define on ProductId also serves to ensure that both ProductId values reference a primary key value in HumanResources.Product.
FIGURE 49.1 Viewing the properties of an xml column in SSMS.
The real-world concept behind this sample ...