O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using XML Schema Collections

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required