Beginning Microsoft SQL Server 2008 ... - S3 Tech Training
Beginning Microsoft SQL Server 2008 ... - S3 Tech Training Beginning Microsoft SQL Server 2008 ... - S3 Tech Training
Chapter 16: A Brief XML Primer SQL Server strips out any whitespace between tags, so if you create a schema collection with all sorts of pretty indentations for readability, SQL Server will remove them for the sake of efficient storage. Creating, Altering, and Dropping XML Schema Collections The CREATE, ALTER, and DROP notions for XML schema collections work in a manner that is mostly consistent with how other such statements have worked thus far in SQL Server. We’ll run through them here, but pay particular attention to the ALTER statement, as it is the one that has a few quirks we haven’t seen in other ALTER statements we’ve worked with. CREATE XML SCHEMA COLLECTION 490 Again, note that the default number of characters returned for text results in Management Studio is only 256 characters. If you’re using text view, you will want to go Tools ➪ Options ➪ Query Results ➪ SQL Server ➪ Results to Text and change the maximum number of characters displayed. Again, the CREATE is your typical CREATE syntax that we’ve seen throughout the book, and uses the AS keyword we’ve seen with stored procedures, views, and other less structured objects: CREATE XML SCHEMA COLLECTION [.] AS { | } So if, for example, we wanted to create an XML schema collection that is similar to the Production .ManuInstructionsSchemaCollection collection in AdventureWorks2008, we might execute something like the following: CREATE XML SCHEMA COLLECTION ProductDescriptionSchemaCollectionSummaryRequired AS ‘
Chapter 16: A Brief XML Primer ’; Note that the URL portion of the namespace declaration must be entered on a single line. It is shown here word wrapped onto multiple lines because there is a limit to the number of characters we can show per line in print. Make sure you include the entire URL on a single line. This one happens to be just like the Production.ManuInstructionsSchemaCollection schema collection, but I’ve altered the schema to require the summary element rather than having it optional. Since the basic structure is the same, I utilized the same namespaces. ALTER XML SCHEMA COLLECTION This one is just slightly different from other ALTER statements in the sense that it is limited to just adding new pieces to the collection. The syntax looks like this: ALTER XML SCHEMA COLLECTION [.] ADD { | } I would not be at all surprised if the functionality of this is boosted a bit in a later service pack, but, in the meantime, let me stress that this is a tool for adding to your schema collection rather than changing or removing what’s there. DROP XML SCHEMA COLLECTION This is one of those classic “does what it says” things and works just like any other DROP: DROP XML SCHEMA COLLECTION [.] 491
- Page 477 and 478: Exclusive Locks Exclusive locks are
- Page 479 and 480: Also: ❑ The Sch-S is compatible w
- Page 481 and 482: The syntax for switching between th
- Page 483 and 484: As with most things in life, howeve
- Page 485 and 486: purchased. Process 2 records sales;
- Page 487: Chapter 14: Transactions and Locks
- Page 490 and 491: Chapter 15: Triggers the world’s
- Page 492 and 493: Chapter 15: Triggers WITH ENCRYPTIO
- Page 494 and 495: Chapter 15: Triggers FOR|AFTER The
- Page 496 and 497: Chapter 15: Triggers 458 To illustr
- Page 498 and 499: Chapter 15: Triggers 460 IF EXISTS
- Page 500 and 501: Chapter 15: Triggers ❑ Feeding de
- Page 502 and 503: Chapter 15: Triggers Trigger Firing
- Page 504 and 505: Chapter 15: Triggers Like regular t
- Page 506 and 507: Chapter 15: Triggers The COLUMNS_UP
- Page 508 and 509: Chapter 15: Triggers This is the sa
- Page 510 and 511: Chapter 15: Triggers 472 we have th
- Page 512 and 513: Chapter 16: A Brief XML Primer So,
- Page 514 and 515: Chapter 16: A Brief XML Primer Figu
- Page 516 and 517: Chapter 16: A Brief XML Primer Elem
- Page 518 and 519: Chapter 16: A Brief XML Primer ❑
- Page 520 and 521: Chapter 16: A Brief XML Primer 482
- Page 522 and 523: Chapter 16: A Brief XML Primer Name
- Page 524 and 525: Chapter 16: A Brief XML Primer The
- Page 526 and 527: Chapter 16: A Brief XML Primer 2. W
- Page 530 and 531: Chapter 16: A Brief XML Primer So,
- Page 532 and 533: Chapter 16: A Brief XML Primer If,
- Page 534 and 535: Chapter 16: A Brief XML Primer 496
- Page 536 and 537: Chapter 16: A Brief XML Primer Note
- Page 538 and 539: Chapter 16: A Brief XML Primer RAW
- Page 540 and 541: Chapter 16: A Brief XML Primer AUTO
- Page 542 and 543: Chapter 16: A Brief XML Primer EXPL
- Page 544 and 545: Chapter 16: A Brief XML Primer Chec
- Page 546 and 547: Chapter 16: A Brief XML Primer 508
- Page 548 and 549: Chapter 16: A Brief XML Primer 510
- Page 550 and 551: Chapter 16: A Brief XML Primer 512
- Page 552 and 553: Chapter 16: A Brief XML Primer The
- Page 554 and 555: Chapter 16: A Brief XML Primer 516
- Page 556 and 557: Chapter 17: Reporting for Duty, Sir
- Page 558 and 559: Chapter 17: Reporting for Duty, Sir
- Page 560 and 561: Chapter 17: Reporting for Duty, Sir
- Page 562 and 563: Chapter 17: Reporting for Duty, Sir
- Page 564 and 565: Chapter 17: Reporting for Duty, Sir
- Page 566 and 567: Chapter 17: Reporting for Duty, Sir
- Page 568 and 569: Chapter 17: Reporting for Duty, Sir
- Page 570 and 571: Chapter 17: Reporting for Duty, Sir
- Page 572 and 573: Chapter 17: Reporting for Duty, Sir
- Page 574 and 575: Chapter 17: Reporting for Duty, Sir
- Page 576 and 577: Chapter 17: Reporting for Duty, Sir
Chapter 16: A Brief XML Primer<br />
<strong>SQL</strong> <strong>Server</strong> strips out any whitespace between tags, so if you create a schema collection with all sorts of<br />
pretty indentations for readability, <strong>SQL</strong> <strong>Server</strong> will remove them for the sake of efficient storage.<br />
Creating, Altering, and Dropping XML Schema Collections<br />
The CREATE, ALTER, and DROP notions for XML schema collections work in a manner that is mostly consistent<br />
with how other such statements have worked thus far in <strong>SQL</strong> <strong>Server</strong>. We’ll run through them<br />
here, but pay particular attention to the ALTER statement, as it is the one that has a few quirks we<br />
haven’t seen in other ALTER statements we’ve worked with.<br />
CREATE XML SCHEMA COLLECTION<br />
490<br />
Again, note that the default number of characters returned for text results in Management<br />
Studio is only 256 characters. If you’re using text view, you will want to go<br />
Tools ➪ Options ➪ Query Results ➪ <strong>SQL</strong> <strong>Server</strong> ➪ Results to Text and change the<br />
maximum number of characters displayed.<br />
Again, the CREATE is your typical CREATE syntax that we’ve seen<br />
throughout the book, and uses the AS keyword we’ve seen with stored procedures, views, and other less<br />
structured objects:<br />
CREATE XML SCHEMA COLLECTION [.] <br />
AS { | }<br />
So if, for example, we wanted to create an XML schema collection that is similar to the Production<br />
.ManuInstructionsSchemaCollection collection in AdventureWorks<strong>2008</strong>, we might execute something<br />
like the following:<br />
CREATE XML SCHEMA COLLECTION ProductDescriptionSchemaCollectionSummaryRequired<br />
AS<br />
‘<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />