From the course: SQL Server 2014 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Working with XML schemas - SQL Server Tutorial
From the course: SQL Server 2014 Essential Training
Working with XML schemas
- Microsoft SQL Server has the ability to store XML schemas and validate XML data against those schemas. Let's go ahead and create an XML schema. I've staged some code for you for this. We'll copy and paste all of that into a new query, and let's look at this before we run it. It starts off with the key word CREATE XML SCHEMA COLLECTION, and then we have to give it a name the name doesn't affect the functionality. Then on line two, the key word AS, the entire rest of this code sample, Lines three through 14, is the XML schema I would like to create. The most important parts of it are lines eight, nine and ten. Line eight defines an element called "FirstName" of data type string, and says it will have a minOccurs of one. The next line defines an element of "LastName", again, data type string and again a minOccurs of one. And then line ten defines an element of "MiddleName", data type string, and minOccurs zero. So this is an optional element. It is okay if it occurs zero times. I'll go…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.