549359 Cover 11/15/02 1:53 PM Page 100% If Microsoft SQL Server 2000 can it, you can it too • SQL Server utilities Paul Nielsen explains how to accomplish database tasks using the graphical tools and using the raw SQL code • Links to Web sites, including the author’s SQL Server Web site, www.IsNotNull.com www.SQLSer verBible.com System Requirements: PC running Windows XP, 2000 Pro, Win NT with SP or later See “What’s on the CD-ROM” appendix for details and complete system requirements *85 -BAHJHh www.wiley.com/compbooks/ $49.99 USA $74.99 Canada £37.50 UK ® BONUS CD-ROM! • Sample database applications and code examples from the book ™ • Design database schemas for performance, adapt integrity, and agility • Understand ACID and Transactional Integrity and build rock-solid databases • Use relational algebra to write powerful queries • Tune indexes as the bridge between data and query • Analyze Query Execution plans for performance to analyze • Create T-SQL stored procedures, triggers, and user-defined functions Learn query execution plans to see • Share data using DTS, distributed queries, XML, and ADO.NET what’s affecting • Analyze data with Analysis Services performance • Add advanced scalability, availability, performance, and portability to your database Microsoft Inside, you’ll find complete coverage of SQL Server development Explore the numerous tasks available within Enterprise Manager SQL Server 2000 Here’s everything you need to harness the power of SQL Server 2000, Microsoft’s high-performance, Web-enabled client/server database and data analysis package With a focus on performance and data integrity, database expert Paul Nielsen shows you how to design performance into your database from day one From basic installation to working with XML, monitoring, and performance tuning — a topic so hot, it merits an entire section — Nielsen provides clear instructions, sound theory, and a special “Best Practice” icon that points to the most effective way to accomplish a given task It’s more than a guidebook; it’s your total SQL Server 2000 toolkit C O M P R E H E N S I V E Reader Level: Shelving Category: Beginning to Advanced SQL Server/Database ISBN 0-7645-4935-9 ,!7IA7G4-fejdfj!:p;o;t;T;T NIELSEN Bible Sample applications, utilities, code examples, and more on CD-ROM 100% ONE HUNDRED PERCENT “Something for everyone this book includes examples to demonstrate concepts along with little-known technical information about SQL Server.” —Melinda S King, President of Best Technology Solutions, Inc COMPREHENSIVE AUTHORITATIVE WHAT YOU NEED ONE HUNDRED PERCENT Master the bestselling client/server database platform Build highperformance, enterprise-class databases Analyze data with advanced SQL techniques Microsoft ® SQL Server 2000 ™ BONUS CD-ROM Includes sample databases, 10,000+ lines of code, SQL Server Utilities, and useful Web links Paul Nielsen 549359 FM.F 11/21/02 4:06 PM Page oi The WILEY advantage Dear Valued Customer, We realize you’re a busy professional with deadlines to hit Whether your goal is to learn a new technology or solve a critical problem, we want to be there to lend you a hand Our primary objective is to provide you with the insight and knowledge you need to stay atop the highly competitive and everchanging technology industry Wiley Publishing, Inc., offers books on a wide variety of technical categories, including security, data warehousing, software development tools, and networking — everything you need to reach your peak Regardless of your level of expertise, the Wiley family of books has you covered • For Dummies – The fun and easy way to learn • The Weekend Crash Course –The fastest way to learn a new tool or technology • Visual – For those who prefer to learn a new topic visually • The Bible – The 100% comprehensive tutorial and reference • The Wiley Professional list – Practical and reliable resources for IT professionals The book you hold now, Microsoft SQL Server 2000 Bible, is your 100% comprehensive guide to developing database projects for SQL Server 2000 If you are new to SQL Server, or client/server technology, SQL Server 2000 Bible is everything you need to incorporate best practices into your database development Beginning with database design theory, Paul Nielsen and his team of experts guide you through developing SQL Server databases, developing data connections, administering SQL Server and keeping your databases performing at their peak with a section on performance tuning and optimization Our commitment to you does not end at the last page of this book We’d want to open a dialog with you to see what other solutions we can provide Please be sure to visit us at www.wiley.com/compbooks to review our complete title list and explore the other resources we offer If you have a comment, suggestion, or any other inquiry, please locate the “contact us” link at www.wiley.com Finally, we encourage you to review the following page for a list of Wiley titles on related topics Thank you for your support and we look forward to hearing from you and serving your needs again in the future Sincerely, Richard K Swadley Vice President & Executive Group Publisher Wiley Technology Publishing more information on related titles 549359 FM.F 11/21/02 4:06 PM Page oii The Next Level of SQL Server Books INTERMEDIATE ADVANCED Available from Wiley Publishing 0-471-21970-3 0-7645-4699-6 Protect information by properly designing and maintaining security at the database level An indispensable reference to Oracle-SQL Server integration 0-7645-4939-5 Covers everything needed to know how to use SQL Server 2000 Available at your favorite bookseller or visit www.wiley.com/compbooks 549359 FM.F 11/21/02 4:06 PM Page i Microsoft SQL Server 2000 Bible ® ™ 549359 FM.F 11/21/02 4:06 PM Page ii 549359 FM.F 11/21/02 4:06 PM Page iii Microsoft SQL Server 2000 Bible ® Paul Nielsen ™ 549359 FM.F 11/21/02 4:06 PM Page iv Microsoft SQL Server 2000 Bible Published by Wiley Publishing, Inc 909 Third Avenue New York, NY 10022 www.wiley.com Copyright © 2003 by Wiley Publishing, Inc., Indianapolis, Indiana ISBN: 0-7645-4935-9 Library of Congress Control Number: 2002110311 Manufactured in the United States of America 10 1B/RT/RS/QS/IN Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada 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) 750-4470 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-4447, E-Mail: permcoordinator@wiley.com LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE APPROPRIATE NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S at 800-762-2974, outside the U.S at 317-572-3993 or fax 317-572-4002 Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available in electronic books Trademarks: Wiley, the Wiley logo and related trade dress are trademarks or registered trademarks of Wiley Publishing, Inc., in the United States and other countries, and may not be used without written permission Microsoft is a trademark or registered trademark of Microsoft Corporation 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 is a trademark of Wiley Publishing, Inc 549359 FM.F 11/21/02 4:06 PM Page v About the Authors Paul Nielsen has been a programmer since 1979 and has focused exclusively on database development since the early ’80s After serving a term with the US Navy Submarine Service as a Data Systems Technician Petty Officer, Paul became a computer trainer and consultant, which led to writing computer magazine articles Paul co-authored a book with Peter Norton in the early ’90s and contributed several chapters to various programming and database books He was the initial technical editor for Access Advisor Magazine, and has spoken at several computer conferences including Microsoft Tech-Ed, and ICCM Over the course of a couple decades, Paul has developed several database projects using a variety of database products and tools Much of the work has centered on the manufacturing industry, and insurance regulation databases Recently, Paul was the data modeler and SQL Server developer for a team that built an MRP/II inventory system Of the 98,000 who have taken the BrainBench.com RDBMS Concepts certification test, at the time of this writing, Paul ranks fifth in the United States Currently, Paul is a database developer with Compassion International, a Christian organization dedicated to releasing children from poverty in Jesus’ name He is also a part-time SQL Server instructor with Learning Tree When not thinking about database development, Paul plays a Taylor guitar, reads the New Living Translation, listens to Natalie Cole, and watches his kids grow up way too fast Brian Patterson currently works as a software developer in central Illinois Brian has been writing for various Visual Basic publications since 1994 and has co-authored several NET related books, including Migrating to Visual Basic NET and C# Bible Brian is exceptionally well rounded and in his spare time he likes to program, write about programming, and read about programming He can generally be found posting in the MSDN newsgroups and is reachable by e-mail at briandpatterson@msn.com Pierre Boutquin is a senior software architect in the treasury of a major Canadian bank, where he helps develop leading-edge market risk management software He has more than a decade of experience implementing PC-based computer systems, along with an in-depth knowledge of distributed systems design, data warehousing, Visual Basic, Visual C++, and SQL He has co-authored many programming books and has also contributed material on C#, VB, COM+, XML, and SQL for others Koshka and Sasha, his two adorable Burmese cats, own most of Pierre’s spare time While petting them, he often thinks how nice it would be to find more time and get back into chess or keep up with news from Belgium, his native country Pierre can be reached at boutquin@hotmail.com Todd Meister is a developer specializing in Microsoft technologies He has been a developer for over 10 years and has published articles for both ActiveWeb Developer and MSDN Magazine Todd can be reached at tmeister@tmeister.com 549359 FM.F 11/21/02 4:06 PM Page vi Credits Senior Acquisitions Editor Sharon Cox Project Coordinator Erin Smith Project Editor Andy Marinkovich Graphics and Production Specialists Sean Decker, Melanie DesJardins, Carrie Foster, Heather Pope Technical Editor Bobbie Townsend Copy Editor Sarah Kleinman Editorial Manager Mary Beth Wakefield Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Bob Ipsen Executive Editorial Director Mary Bednarek Quality Control Technicians John Tyler Connoley, Andy Hollandbeck Proofreading and Indexing TECHBOOKS Production Services, Johana VanHoose 549359 Index.F 11/21/02 9:52 AM Page 883 Index ✦ S queries, using within, 413–414 record set, returning, 405 remote, executing, 416 returning data output parameters, 410–411 path and scope, 412–413 return command, 411–412 system, 408 Visual Basic, 743 SQL for Smarties, Advanced SQL Programming (Joe Celko), 835 SQL, language specific to SQL Server See T-SQL SQL Profiler background, 761 browsing, 760–761 trace data columns, 759–760 trace events, 757–759 SQL queries, 373 SQL script catalogs, configuring with T-SQL Code, 271–272 databases, transferring, 501–503 tables, creating, 125–126 SQL Server accessing with Server Explorer, 580–582 advantages, 8–13 applications connecting to, 25–27 authentication mode, 720–721 Books On-Line (BOL), 22–23 certifications and training, 27–30 client/server database model, 4–7 command-line utilities (Isql, osql, Bulk Copy), 22 data sources, moving among (Data Transformation Services), 19 databases, working with, 582–584 distributed transactions, 24 DTC, 18 editions, discussed, 13–16 engine, 17 Enterprise Manager, 21 licensing, 16 login, 720, 726–729 monitoring, 754–761 Net and, 30–32 network utilities, 21 performance counters, current status (Performance Monitor), 23 Query Analyzer, 21–22, 23 reading XML into, 610–612 Resource Kit, 24 server components, 17–20 server network utility, 21 specifications, 847–850 SQL Server 2000, creating XML with, 608–610 traffic and events, recording (SQL Profiler), 23 Transact SQL, 24–25 transfer tasks, 539 XML, 24, 608–610 SQL Server Agent alerts, 674–679 database management, setting up, 671–674 described, 17–18 jobs category, creating, 680–681 completion-, success-, and failure-notification messages, 685 definition, creating, 681–682 schedule, configuring, 684–685 steps, setting up, 682–684 MSDB system database recovery, 713–714 operators, 675–676 SQLXML queries HTTP queries, 617–618 template queries, 618–620 virtual directories, 615–617 stacking result sets rows common to both data sets, finding (intersection union), 246–248 rows found in only one of data sets (difference union), 249–250 standard database roles, 736–738 Standard Edition, 15 standard select statement cursors, 390–391 standby availability crash, detecting and handling, 790 going live, 790–791 log shipping configuring, 781–783 job, creating, 787–788 monitoring, 784 read-only standby query server, 788–789 roles, switching, 784–785 servers, 781 stored procedures, 785–786 original primary server, returning to, 791 SQL Server Agent, 785–789 users, shipping, 790 star (*), 164, 280 Star Schema cubes, 816–817 883 549359 Index.F 884 11/21/02 9:52 AM Page 884 Index ✦ S start/stop failure, indicating corrupt master database, 710 properties system administration, 631–632 start-up stored procedure, system administration, 632 statement permissions, 733–734 statistics DBCC commands, 661 updating (statistics norecompute option) indexes, 153 stockbroker problem, sample query, 264–266 stored messages, error handling, 398–399 stored procedures ADO.NET, 586–589 attached to table events after, 437–438 behavior, configuring, 651 creating, 437 data integrity, 53–54 described, 435–436 disabling, 439 instead of, 438–439, 834 limitations, 439 listing, 439–440 logically deleting data, 489–490 multiple-trigger interaction, 444–447 performance, advanced, 762 security, 440 transaction flow, 436–437 transaction, working with, 440–444 compiling, 405–406 create, alter, and drop, 404 database access, 731 debugging, 414–415 described, 403–404, 416–424 encryption, 406–407 log shipping with SQL Server Agent, 785–787 managing, 404–408 order, adding, 423–424 passing data, 408–410 permission to execute, 735 pGetPrice stored procedure, 417–418 pOrder_AddItem stored procedure, 421–423 pOrder_AddNew stored procedure, 419–421 queries, using within, 413–414 record set, returning, 405 remote, executing, 416 returning data, 410–413 system, 408 Visual Basic, 743 string concatenation, 167 patterns within, searching, 177–179 scalar functions, retrieving data, 196–199 structure data integrity (primary key and attributes), 53 DTDs, 602–603 style sheets XML publishing, 596–597 XSL, transforming with, 613–614 subqueries as lists, 238–241 scalar, 236–237 simple, 234–236 as tables, 241–243 subscriptions MSDN Universal, 16 publication pulling, 557 pushing, 556 removing replication, 557 subscribing, 555 success-notification messages, 685 summary data, pre-calculated Analysis Manager, 813–815, 826–828 creating data source, 819–820 data warehouse, 818–819 shared dimensions, 820–825 Snowflake schema, 817–818 Star schema, 816–817 storage, 825–826 Excel, 828–830 external applications, accessing, 809 storage, 825–826 summing data aggregate functions, 205–208 filtering results, 210–213 generating totals, 213–214 within a result set, 208–210 super-type/sub-type relationships, 43–44 symbols, error-causing, 601 system described, 84–85 index statistics and fill-factor options, 645–646 stored procedures, developing, 408 system administration configuration ANSI behavior, 648–650 auto options, 646–647 connection, 630, 641–643 cursor, 647–648 database state, 652–653 index statistics and fill-factor options, 645–646 memory, 632–636 processor, 637–639 recovery options, 653–654 security, 640–641 549359 Index.F 11/21/02 9:52 AM Page 885 Index ✦ S–T server, 625–628, 643–645 start/stop properties, 631–632 trigger behavior, 651 database security, 729–734 maintenance automating, 674–679 command-line, 669 Database Maintenance Plan Wizard, 666–668 DBCC commands, 655–665 jobs, 680–685 monitoring, 669 planning, 665 object security Enterprise Manager, 738–742 ownership, 743–745 permissions, 735–736 sample security model, 745–746 standard database roles, 736–738 recovery plans complete, performing, 714 concepts, 687–688 database, backing up, 693–698 Enterprise Manager, performing restore with, 703–705 Master System, 710–712 models, 688–693 MSDB System, 713–714 problems, detecting, 702 reasons to restore database, 701–702 sequences, 702–703 System Databases, 709–714 transaction log, 698–701 T-SQL Code, performing restore with, 706–709 security concepts, 717–719, 727, 746–747 server security authentication mode, 720–726 logins, 726–729 views and, 747–748 Windows security, 719–720 system performance accuracy, measuring, 752–753 advantages of client/server model, constraints and triggers, 762 counters, current status, 23 cursors, 386 data changes, auditing, 479 database design and performance, 114, 761–762 goals, 751 indexing base, 770 clustered, 768 database size, 147 nonclustered, 768 OLTP versus OLAP, 769 primary keys, 768–769 tuning, 770–776 locking, 776–777 multiple SQL instances, running, 66 optimization cycle, 752 query design and performance, 763–768 response time, measuring, 753–754 scalability and, 9–10 SQL Server, monitoring, 754–761 views, creating, 298–300 system tables allowing changes, 644–645 code, developing, 834 listed, 86 T table creating within Enterprise Manager, 124–125 filegroups, 128 SQL Scripts, working with, 125–126 table and column names, 126–127 while inserting data, 310–313 database basics, 34–35 design, creating indexes, 149 design view in Enterprise Manager, 99 duplicating for distinct purposes, 116 events, stored procedures attached to after, 437–438 behavior, configuring, 651 creating, 437 data integrity, 53–54 described, 435–436 disabling, 439 instead of, 438–439, 834 limitations, 439 listing, 439–440 logically deleting data, 489–490 multiple-trigger interaction, 444–447 performance, advanced, 762 security, 440 transactions, 436–437, 440–444 indexed views, 794 names, 126–127 organizing, 154 perspective, locking, 357 publishing portion of, 554 referring back to same (self-joins), 229–230 result sets, stacking (union) rows common to both data sets, finding (intersection union), 246–248 rows found in only one of data sets (difference union), 249–250 Continued 885 549359 Index.F 886 11/21/02 9:52 AM Page 886 Index ✦ T table (continued) retrieving data with select, 171–172 select statement embedded within outer query (subqueries), 241–243 single, retrieving data with Select (subentries), 158–185 system allowing changes, 644–645 code, developing, 834 listed, 86 temporary, 379–380 variables, database programming with T-SQL, 380 tape-backup devices, 693–694 Taskpad, 96, 98 tasks, multiple competing for same resource, 360–363 TCSEC (Department of Defense Trusted Computer System Evaluation Criteria), 641, 717 telephone book, 771 template browser, allowing queries from (SQLXML), 618–620 data retrieval and modification (Query Analyzer), 106 temporary tables global, 380 local, 379 Terra Server project example, 10 testing installation, 74 nulls, 185–187 text catalogs, creating with wizard, 269–270 and image size sent via replication, maximum, 643 search default language, 644 stored procedure, retrieving, 406–407 title case, converting to, 198–199 XML documents, 601 theta (Θ) join, 232 third-party products load-testing, 734 resources, listed, 836 threads, max worker, 638 threshold, cursor, 648 time back-ups, performing, 690 column data types, 139 merging data, 260–264 scalar functions, retrieving data (datatime), 193–195 timeout locking, 358 system configuration, 643 tools, developer actions, selecting, and properties, viewing (rightclick menu), 97 data retrieval, 101–102, 155–158 database diagrams (Database Designer), 100–101 described, 91 menus and toolbars, 97 MMC add-in, 91–92 objects, viewing available, 93–96 processes, starting and stopping, 89–91 Query Analyzer data retrieval and modification, 104–107 server, connecting to, 92–93 Table Design view, 99 Taskpad, 96 top 10 annoyances, 102–103 wizards, 98–99 torn-page detection, 654 Total SQL Analyzer (FMS), 154, 836 TPC (Transaction Processing Council), trace events background, 761 browsing, 760–761 data columns, 759–760 described, 755, 757–759 traffic, recording, 23 trail, audit fixed trigger, data changes, 473–476 rolling back from, 477–478 training benefits, 27 conferences, 30 Learning Tree SQL Server 2000 certifications, 29 Microsoft Certified DBA certification, 28–29 Microsoft Certified Professional program, 28 on-line independent certification company (Brainbench.com), 29 Transact SQL See T-SQL transaction defined, 335–337 dual-phase commits spanning multiple SQL Servers, 18, 526, 643 flow triggers, 436–437 triggers, working with, 440–444 549359 Index.F 11/21/02 9:52 AM Page 887 Index ✦ T–U transaction log backing up and shipping to backup server described, 781–785 job, creating, 787–788 read-only standby query server, 788–789 stored procedures, initializing, 785–787 warm-standby availability, 790 location, 63, 117 recovery planning, 698–701 shrinking, 664 Transaction Processing Council See TPC transactional consistency, 548 transactional faults, 338–343 transactional integrity ACID properties, 337–338 application locking design, 363–366 isolation levels, 343–344 locking controlling, 355–359 duration, 353 granularity, 350–351 mode, 351–353 viewing, 353–355 log architecture, 344–349 multiple tasks competing for same resource (deadlocks), 360–363 transaction, defined, 335–337 transactional faults, 338–343 transformations, 533–539 tree hierarchy elements, DTDs (Document Type Definitions) structure, 602–603 set-based solution, 393–394 standard select statement, 390–391 triggers, 445, 651 unique indexes, 152 views, creating, 300–302 triggers after, 437–438 behavior, configuring, 651 creating, 437 data integrity, 53–54 described, 435–436 disabling, 439 instead of, 438–439, 834 limitations, 439 listing, 439–440 logically deleting data, 489–490 multiple-trigger interaction, 444–447 performance, advanced, 762 security, 440 transaction, 436–437, 440–444 true/false statements case expressions, 170–171 exclusive or, 168–169 not, 169 table, retrieving data with select, 167–168 T-SQL procedural flow, 374–376 user-defined rules, 145–146 where conditions, combining multiple, 179–180 truncating transaction log, 701 T-SQL (Transact SQL) access, granting, 726, 731 described, 24–25 distributed queries, working with, 512–515 filegroups, creating, 123 fixed database roles, assigning with, 733 raw batches, executing filegroups, modifying, 123 retrieving data with Select, 157–158 SQL Server client components, 21–22, 23 stored procedures, debugging, 414–415 restore, performing, 706–709 scripts, 126 string functions, 196–199 tuples attribute, assigned (primary key), 38 on each side (cardinality), 40–41 two-digit-year cutoff, server display, 645 U unattended installation, 73–74 Unicode, 64, 126, 138 union rows common to both data sets, finding (intersection union), 246–248 rows found in only one of data sets (difference union), 249–250 unique constraints, 142–143 unique indexes indexes, creating, 152 obstacles to modifying data, 328 unique values, 140 uniqueidentifier data type, 131–132 887 549359 Index.F 11/21/02 888 Index ✦ U–V 9:52 AM Page 888 Update Data Optimization Information Screen, 666 updated tables code, developing, 833 creating, 800 distributed-partition view, 806–808 local-partition view creating, 800 moving data, 803–805 segmenting data, 797–800 selecting through, 800–802 updating through, 802–803 selecting, 800–802 updating columns, triggering when, 440–442 database auto options, 647 global search and replaces, 314–315 indexed views and queries, 796 keys, 129 mode, locking, 352 multiple tables, referencing, 315–318 OLTP database, 34–35 permission, 735 publications, 555–557 security table, 466–468 single table, 313–314 viewing before committing, 338–340 views, allowing, 297–298 uppercase, converting string to, 197, 198 upsizing from Access, 77–81 U.S geological survey photos, 10 user authentication mode, 65 concurrent data retrieval and modification, 337 connections, measuring, 757 data columns calculated, 140–141 column data types, 137–140 constraints and defaults, 141–145 data catalog, 145–146 database-level security, 718–719 databases, recovery bulk-logged, 692 concepts, 687–688 database, backing up, 693–698 Enterprise Manager, performing restore with, 703–705 full, 690–691 master database failure, 711 modifying, 693 options, configuring, 653–654 problems, detecting, 702 reasons to restore database, 701–702 sequences, 702–703 setting, 692–693 simple, 689–690 transaction log, 698–701 identifying, 718–719 information, retrieving, 193 list, 740–741 load testing, 754 primary key, protecting from, 129–130 shipping, warm-standby availability, 790 user-defined data catalog rules, 145–146 data integrity, 53–54 data type, 141–142, 146 error alerts, 676–679 functions code, developing, 833 inline table-valued functions, 428–431 multistatement table-valued functions, 431–432 permission to execute, 735 scalar functions, 425–428 V validation keys, creating, 129–130 performance, advanced, 762 user-data columns, 141–145 XML, 597 variables database programming with T-SQL, 371–373 variable-word-weight word searches, 282–283 variant data, 140 Venn diagrams, 216 verifying database with code, 698 log files, 702 versions data connectivity, 544–545 versions, SQL Server CE edition, 16 Enterprise (Developer) edition, 13–15 Microsoft Developer Network (MSDN), 16 MSDE/Desktop Edition, 16 Personal Edition, 15–16 Standard Edition, 15 view ad hoc queries, 293 alternatives, 301 549359 Index.F 11/21/02 9:52 AM Page 889 Index ✦ V–W with check option, 294–295 database security and, 747–748 DDL (Data Definition Language) code, 291–292 described, 289–290 distributed queries, working with, 519 distributed-partition tables, 805–808 Enterprise Manager, 290–291 indexes, 13, 116, 148 local-partition tables creating, 800 moving data, 803–805 segmenting data, 797–800 selecting through, 800–802 updating through, 802–803 locking, 353–355 nested, 300–302 order by clause, 295–296 with order by code, developing, 834 performance problems, 298–300 protecting, 296–297 query-optimization plans and execution statistics filegroups, modifying, 123 retrieving data with Select, 157–158 SQL Server client components, 21–22, 23 stored procedures, debugging, 414–415 restrictions, 292–293 updatable, 297–298 XML, 595–596 virtual directories, allowing queries from browser (SQLXML), 615–617 visible entities, 38 Visio, 27, 154 Visual Basic, 743 Visual Studio projects, 586–589 W warehousing tasks, 541 warm-standby server crash, detecting and handling, 790 Enterprise edition, 781–785 going live, 790–791 log shipping configuring, 781–783 job, creating, 787–788 monitoring, 784 read-only standby query server, 788–789 roles, switching, 784–785 servers, 781 stored procedures, 785–78 original primary server, returning to, 791 SQL Server Agent, 785–789 users, shipping, 790 warnings, 650, 674–679 Web browser, allowing queries from (SQLXML) HTTP queries, 617–618 template queries, 618–620 virtual directories, 615–617 Web pages described, 835–836 security, supporting, 719–720 Web, publishing data on, 620–621 Web sites, addresses listed author, 835 certification programs, 28, 29, 835 conferences, 30 corporate databases, sample running on SQL Server 2000, groups and organizations, 836 publications, 835 service packs, 813 SQL Server versus Oracle, 835 TerraServer, 10 third-party products, 836 Venn diagrams, 216 where conditions table, retrieving data with Select, 172–176 where table, retrieving data with Select, 179–180 wildcard columns in table order, 164 patterns within string, searching, 177–179 searches, 280 Windows (Microsoft) disks, managing, 69 error messages, calling, 398–400 language, selected, 63 security based on, 719–726 SQL Server editions, 13–16 SQL Server running inside, 3, 61–62 word/phrase indexing system, 267 with check option view, 294–295, 333–334 with ties option rows, returning few (top keyword), 163 wizards Access, upsizing from, 78–80 Copy Database Wizard, 498–501 Create Index Wizard, 147–148 Database Maintenance Plan Wizard, 666–668 Developer Tools, 98–99 Tuning Wizard, 774–776 889 549359 Index.F 11/21/02 9:52 AM 890 Index ✦ W–Z Page 890 word searches binary objects, 285–286 English basis, specifying, 18 indexes, searching full-text, 267–268, 276–285 variable-word-weight, 282–283 word-inflection based on common root, 281–282 word-proximity (near option), 280–281 workflow precedence, 542 write, cascading during, 491 X XML (eXtensible Markup Language) auto, 609–610 documents, 598–601 DTDs (Document Type Definitions), 602–605 EDI (Electronic Data Interchange) and, 594–595 Net, 31 parsing, 595 publishing, 596–597 queries from browser (IIS Virtual Directory Manager), 24 validation, 597 viewing, 595–596 XPath, 615 XSL (eXtensible Stylesheet Language) schema document, 606–608 transforming with, 612–615 Y years, two-digit-year cutoff, server display, 645 6549359 EULA.F 11/21/02 9:52 AM Page 891 Wiley Publishing, Inc End-User License Agreement READ THIS You should carefully read these terms and conditions before opening the software packet(s) included with this book “Book” This is a license agreement “Agreement” between you and Wiley Publishing, Inc.”WPI” By opening the accompanying software packet(s), you acknowledge that you have read and accept the following terms and conditions If you not agree and not want to be bound by such terms and conditions, promptly return the Book and the unopened software packet(s) to the place you obtained them for a full refund License Grant WPI grants to you (either an individual or entity) a nonexclusive license to use one copy of the enclosed software program(s) (collectively, the “Software” solely for your own personal or business purposes on a single computer (whether a standard computer or a workstation component of a multi-user network) The Software is in use on a computer when it is loaded into temporary memory (RAM) or installed into permanent memory (hard disk, CD-ROM, or other storage device) WPI reserves all rights not expressly granted herein Ownership WPI is the owner of all right, title, and interest, including copyright, in and to the compilation of the Software recorded on the disk(s) or CD-ROM “Software Media” Copyright to the individual programs recorded on the Software Media is owned by the author or other authorized copyright owner of each program Ownership of the Software and all proprietary rights relating thereto remain with WPI and its licensers Restrictions On Use and Transfer (a) You may only (i) make one copy of the Software for backup or archival purposes, or (ii) transfer the Software to a single hard disk, provided that you keep the original for backup or archival purposes You may not (i) rent or lease the Software, (ii) copy or reproduce the Software through a LAN or other network system or through any computer subscriber system or bulletin- board system, or (iii) modify, adapt, or create derivative works based on the Software (b) You may not reverse engineer, decompile, or disassemble the Software You may transfer the Software and user documentation on a permanent basis, provided that the transferee agrees to accept the terms and conditions of this Agreement and you retain no copies If the Software is an update or has been updated, any transfer must include the most recent update and all prior versions Restrictions on Use of Individual Programs You must follow the individual requirements and restrictions detailed for each individual program in the About the CD-ROM appendix of this Book These limitations are also contained in the individual license agreements recorded on the Software Media These limitations may include a requirement that after using the program for a specified period of time, the user must pay a registration fee or discontinue use By opening the Software packet(s), you will be agreeing to abide by the licenses and restrictions for these individual programs that are detailed in the About the CD-ROM appendix and on the Software Media None of the material on this Software Media or listed in this Book may ever be redistributed, in original or modified form, for commercial purposes 6549359 EULA.F 11/21/02 9:52 AM Page 892 Limited Warranty (a) WPI warrants that the Software and Software Media are free from defects in materials and workmanship under normal use for a period of sixty (60) days from the date of purchase of this Book If WPI receives notification within the warranty period of defects in materials or workmanship, WPI will replace the defective Software Media (b) WPI AND THE AUTHOR OF THE BOOK DISCLAIM ALL OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE SOFTWARE, THE PROGRAMS, THE SOURCE CODE CONTAINED THEREIN, AND/OR THE TECHNIQUES DESCRIBED IN THIS BOOK WPI DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED IN THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE SOFTWARE WILL BE ERROR FREE (c) This limited warranty gives you specific legal rights, and you may have other rights that vary from jurisdiction to jurisdiction Remedies (a) WPI’s entire liability and your exclusive remedy for defects in materials and workmanship shall be limited to replacement of the Software Media, which may be returned to WPI with a copy of your receipt at the following address: Software Media Fulfillment Department, Attn.: Microsoft SQL Server 2000 Bible, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, or call 1-800-762-2974 Please allow four to six weeks for delivery This Limited Warranty is void if failure of the Software Media has resulted from accident, abuse, or misapplication Any replacement Software Media will be warranted for the remainder of the original warranty period or thirty (30) days, whichever is longer (b) In no event shall WPI or the author be liable for any damages whatsoever (including without limitation damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising from the use of or inability to use the Book or the Software, even if WPI has been advised of the possibility of such damages (c) Because some jurisdictions not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation or exclusion may not apply to you U.S Government Restricted Rights Use, duplication, or disclosure of the Software for or on behalf of the United States of America, its agencies and/or instrumentalities “U.S Government” is subject to restrictions as stated in paragraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause of DFARS 252.227-7013, or subparagraphs (c) (1) and (2) of the Commercial Computer Software - Restricted Rights clause at FAR 52.227-19, and in similar clauses in the NASA FAR supplement, as applicable General This Agreement constitutes the entire understanding of the parties and revokes and supersedes all prior agreements, oral or written, between them and may not be modified or amended except in a writing signed by both parties hereto that specifically refers to this Agreement This Agreement shall take precedence over any other documents that may be in conflict herewith If any one or more provisions contained in this Agreement are held by any court or tribunal to be invalid, illegal, or otherwise unenforceable, each and every other provision shall remain in full force and effect 6549359 EULA.F 11/21/02 9:52 AM Page 893 6549359 EULA.F 11/21/02 9:52 AM Page 894 6549359 EULA.F 11/21/02 9:52 AM Page 895 6549359 EULA.F 11/21/02 9:52 AM Page 896 549359 Cover 11/15/02 1:53 PM Page 100% If Microsoft SQL Server 2000 can it, you can it too • SQL Server utilities Paul Nielsen explains how to accomplish database tasks using the graphical tools and using the raw SQL code • Links to Web sites, including the author’s SQL Server Web site, www.IsNotNull.com www.SQLSer verBible.com System Requirements: PC running Windows XP, 2000 Pro, Win NT with SP or later See “What’s on the CD-ROM” appendix for details and complete system requirements *85 -BAHJHh www.wiley.com/compbooks/ $49.99 USA $74.99 Canada Ê37.50 UK đ BONUS CD-ROM! ã Sample database applications and code examples from the book ™ • Design database schemas for performance, adapt integrity, and agility • Understand ACID and Transactional Integrity and build rock-solid databases • Use relational algebra to write powerful queries • Tune indexes as the bridge between data and query • Analyze Query Execution plans for performance to analyze • Create T-SQL stored procedures, triggers, and user-defined functions Learn query execution plans to see • Share data using DTS, distributed queries, XML, and ADO.NET what’s affecting • Analyze data with Analysis Services performance • Add advanced scalability, availability, performance, and portability to your database Microsoft Inside, you’ll find complete coverage of SQL Server development Explore the numerous tasks available within Enterprise Manager SQL Server 2000 Here’s everything you need to harness the power of SQL Server 2000, Microsoft’s high-performance, Web-enabled client/server database and data analysis package With a focus on performance and data integrity, database expert Paul Nielsen shows you how to design performance into your database from day one From basic installation to working with XML, monitoring, and performance tuning — a topic so hot, it merits an entire section — Nielsen provides clear instructions, sound theory, and a special “Best Practice” icon that points to the most effective way to accomplish a given task It’s more than a guidebook; it’s your total SQL Server 2000 toolkit C O M P R E H E N S I V E Reader Level: Shelving Category: Beginning to Advanced SQL Server/Database ISBN 0-7645-4935-9 ,!7IA7G4-fejdfj!:p;o;t;T;T NIELSEN Bible Sample applications, utilities, code examples, and more on CD-ROM 100% ONE HUNDRED PERCENT “Something for everyone this book includes examples to demonstrate concepts along with little-known technical information about SQL Server.” —Melinda S King, President of Best Technology Solutions, Inc COMPREHENSIVE AUTHORITATIVE WHAT YOU NEED ONE HUNDRED PERCENT Master the bestselling client/server database platform Build highperformance, enterprise-class databases Analyze data with advanced SQL techniques Microsoft ® SQL Server 2000 ™ BONUS CD-ROM Includes sample databases, 10,000+ lines of code, SQL Server Utilities, and useful Web links Paul Nielsen ... 4:06 PM Page i Microsoft SQL Server 2000 Bible ® ™ 549359 FM.F 11/21/02 4:06 PM Page ii 549359 FM.F 11/21/02 4:06 PM Page iii Microsoft SQL Server 2000 Bible ® Paul Nielsen ™ 549359 FM.F 11/21/02... comprehensive guide to developing database projects for SQL Server 2000 If you are new to SQL Server, or client /server technology, SQL Server 2000 Bible is everything you need to incorporate best practices... Selecting the Right SQL Server 2000 Edition 13 Enterprise (Developer) Edition 13 Standard Edition 15 Personal Edition