Professional
SQL Server
™
2005 XML
Scott Klein
01_597922 ffirs.qxp 12/3/05 12:24 AM Page i
Professional
SQL Server
™
2005 XML
Scott Klein
01_597922 ffirs.qxp 12/3/05 12:24 AM Page i
Professional SQL Server
™
2005 XML
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN-13: 978-0-7645-9792-3
ISBN-10: 0-7645-9792-2
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1MA/SR/RS/QV/IN
Library of Congress Cataloging-in-Publication Data:
Klein, Scott, 1966-
Professional SQL Server 2005 XML / Scott Klein.
p. cm.
Includes index.
ISBN-13: 978-0-7645-9792-3 (paper/website)
ISBN-10: 0-7645-9792-2 (paper/website)
1. SQL server. 2. Client/server computing. 3. XML (Document markup language) I. Title.
QA76.9.C55K545 2005
005.2’768--dc22
2005029721
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should
be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256,
(317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP-
RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CON-
TENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED
OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED
HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING
THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFES-
SIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PRO-
FESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALLBE LIABLE
FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO
IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT
MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR
WEBSITE MAY
PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE
AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED
BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services please contact our Customer Care Department within
the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other
countries, and may not be used without written permission. All other trademarks are the property of their respective
owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.
01_597922 ffirs.qxp 12/3/05 12:24 AM Page ii
About the Author
Scott Klein is a software developer and architect, and his passion for SQL Server, .NET, and all things
XML led him to Greenville, South Carolina, where he currently works as a SQL/.NET developer for CSI,
a software solutions company. He has written several articles for TopXML (
www.TopXLM.com) and is a
frequent speaker at SQL Server and .NET user groups around Greenville and the surrounding areas.
When he is not sitting in front of a computer or spending time with his family, he can usually be found
aboard his Yamaha at the local motocross track.
Acknowledgments
Writing a book is a daunting task. Writing your first book is just downright intimidating. The better the
support people you have assisting and guiding you, the easier the task becomes. Therefore, it is only
appropriate to thank those individuals who made this project much easier than it could have been.
First and foremost, Clay Andres for sticking with the book idea when it seemed like the idea wasn’t
going anywhere.
A huge thanks to the folks at Wiley for making this book happen. Brian Herrmann, my awesome devel-
opment editor, was truly that. With my being a first time book author, Brian was a tremendous help and
a sheer delight to work with. Thanks, Brian.
Thanks also to Jim Minatel, for accepting the book idea and letting me write it, and to Derek Comingore,
for technically reviewing this book and providing priceless feedback and help. Thank you, Derek.
I would be remiss if I didn’t mention the following individuals for their assistance in providing informa-
tion. Primarily, I must thank Irwin Dolobowsky, my main contact at Microsoft. Irwin was my go-to guy,
a life saver on many occasions. If he didn’t know the answer, he knew who did or would find out who
did. Also included in the list of Microsoft people to thank are Michael Rys, Arpan Desai, Srik Raghavan,
Mark Fussell, Vineet Rao, and Beysim Sezgin. Thank you, to all of you.
Enough cannot be said about the love and support of my family. For my wife, Lynelle, who held the
house together for the 8+ months I spent upstairs. And to my children, who were patient with their
father knowing that they soon would get their dad back. I love you all.
I can only hope the next book is less daunting.
01_597922 ffirs.qxp 12/3/05 12:24 AM Page iii