Sample Content from Programming Microsoft SQL Server 2005
Total Page:16
File Type:pdf, Size:1020Kb
Programming Microsoft® SQL Server™ 2005 Andrew J. Brust, Stephen Forte To learn more about this book, visit Microsoft Learning at http://www.microsoft.com/MSPress/books/9153.aspx 9780735619234 Publication Date: December 2004 A05T619239.fm Page vii Tuesday, May 31, 2005 9:13 PM Table of Contents Acknowledgements . xix Introduction . xxiii Who This Book Is For . xxiv How This Books is Organized . xxv System Requirements. xxvi Using the Samples . xxvii Support for This Book . xxix Questions and Comments. xxix Part I Design Fundamentals and Core Technologies 1 Overview . .3 A Tough Act to Follow . .3 The Software Industry and Disruptive Change . 3 Industry Trends, SQL Server Features, and a Book to Show You the Way . 4 Programming the Server. 4 Application Code and SQL Server: Extending Your Database’s Reach . 5 It’s the Strategy, Stupid . 7 A Collaborative Effort for, and by, Developers. 9 2 Exploring the T-SQL Enhancements in SQL Server 2005 . 11 Introducing SQL Server Management Studio . 12 Common Table Expressions. 13 Recursive Queries with CTEs . 16 The PIVOT and UNPIVOT Operators . 20 Using UNPIVOT . 21 Dynamically Pivoting Columns. 22 The APPLY Operator. 24 TOP Enhancements . 25 Ranking Functions . .26 ROW_NUMBER(). 26 RANK() . 30 DENSE_RANK() and NTILE(n) . 32 Using All the Ranking Functions Together . 34 Ranking over Groups: PARTITION BY . 35 Microsoft is interested in hearing your feedback about this publication so we can What do you think of this book? continually improve our books and learning resources for you. To participate in a brief We want to hear from you! online survey, please visit: www.microsoft.com/learning/booksurvey/ vii A05T619239.fm Page viii Tuesday, May 31, 2005 9:13 PM viii Table of Contents Exception Handling in Transactions . 38 New Data Types . 40 varchar(max) Data Type . 40 xml Data Type. 40 The WAITFOR Command . 41 DDL Triggers and Notifications . 42 SNAPSHOT Isolation . 43 Statement-Level Recompile . 44 Summary . 44 3 An Overview of SQL CLR. 45 Getting Started: Enabling CLR Integration. 46 Visual Studio/SQL Server Integration . 48 SQL Server Projects in Visual Studio . 49 Automated Deployment. 51 SQL CLR Code Attributes . 52 Your First SQL CLR Stored Procedure . 53 CLR Stored Procedures and Server-Side Data Access. 55 Piping Data with SqlDataRecord and SqlMetaData . 57 Deployment . 59 Deploying Your Assembly. 59 Deploying Your Stored Procedures . 61 Testing Your Stored Procedures. 63 CLR Functions . 65 CLR Triggers . 69 CLR Aggregates . 74 CLR Types . 78 Security . 84 Examining and Managing CLR Types in a Database . 85 Best Practices for SQL CLR Usage . 91 Summary . 92 4 XML and the Relational Database . 93 XML in SQL Server 2000 . 95 The XML Data Type . 96 Working with the XML Data Type as a Variable . 96 Working with XML in Tables . 98 XML Schemas . 99 XML Indexes . 102 FOR XML Commands . 105 FOR XML RAW . 106 FOR XML AUTO.