[...]... of Creating Scripts with the Management Studio Summary Exercises xviii 11 7 11 7 11 8 11 9 11 9 11 9 11 9 12 0 12 0 12 0 12 0 12 1 12 1 12 1 12 3 12 4 12 5 12 6 12 6 12 6 12 7 12 8 12 8 12 8 12 8 13 0 13 0 13 0 13 0 13 6 13 6 13 9 14 0 14 3 14 4 14 5 15 0 15 1 15 2 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xix Contents Chapter 6: Constraints 15 3 Types of Constraints 15 4 Domain Constraints Entity Constraints Referential Integrity Constraints... Nested Queries Using Subqueries That Return Multiple Values Using a Nested SELECT to Find Orphaned Records 15 4 15 4 15 5 15 6 15 7 15 7 15 8 15 9 16 0 16 1 16 2 16 4 16 9 17 0 17 1 17 2 17 3 17 4 17 5 17 5 17 6 17 8 18 0 18 0 18 2 18 2 18 2 18 3 18 3 18 3 18 5 18 7 18 8 18 9 18 9 19 0 19 1 xix 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xx Contents Correlated Subqueries How Correlated Subqueries Work Correlated Subqueries in the WHERE... and Altering T ables Object Names in SQL Ser ver 64 64 67 72 73 75 77 78 79JOINs 81 83 88 88 90 91 91 94 94 94 97 10 1 10 3 10 3 10 4 10 5 10 5 10 6 10 7 10 9 11 1 11 2 11 3 11 3 Schema Name (aka Ownership) 11 4 A Little More About Schemas The Default Schema: dbo 11 4 11 5 The Database Name Naming by Server Reviewing the Defaults 11 6 11 6 11 7 xvii 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xviii Contents The CREA TE... Defaults User-Defined Data Types Full-Text Catalogs SQL Ser ver Data T ypes NULL Data SQL Ser ver Identifiers for Objects What Gets Named? Rules for Naming Summary xxxi 1 1 2 3 4 4 5 5 5 5 6 6 6 6 6 7 7 8 8 8 8 9 10 10 11 11 11 11 12 12 18 18 18 19 19 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xvi Contents Chapter 2:T ools of the T rade Books Online SQL Ser ver Configuration Manager Service Management... PATH 10 1 OPENXML A Brief W ord on XSLT Summary xxviii 473 474 475 475 476 477 478 479 479 480 483 484 485 486 486 487 488 490 490 4 91 4 91 492 492 493 494 495 497 498 498 498 500 502 503 504 505 509 514 516 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xxix Contents Chapter 17 : Repor ting for Duty, Sir! A Look At Repor ting Ser vices Reporting Ser vices 10 1 Building Simple Repor t Models 517 518 518 Data... ? Summary Exercises Chapter 8: Being Nor mal: Nor malization and Other Basic Design Issues 19 2 19 2 19 2 19 5 19 6 19 7 200 202 203 206 209 210 212 212 214 214 215 Tables Keeping Your Data “Nor mal” 216 216 Before the Beginning The First Normal Form The Second Normal Form The Third Normal Form Other Normal Forms 217 260 260 260 260 Relationships 260 One-to-One 260 Zero or One-to-One 260 One-to-One or Many... 57 012 ffirs.qxd:WroxBeg 11 /24/08 4:52 PM Page xiv 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xv Contents Introduction Chapter 1: RDBMS Basics: What Mak es Up a SQL Ser ver Database? An Over view of Database Objects The Database Object The master Database The model Database The msdb Database The tempdb Database ReportServer ReportServerTempDB AdventureWorks2008 AdventureWorksLT2008 AdventureWorksDW2008... Verification Command Line Executing the Package Executing Using the SQL Server Agent Executing a Package from Within a Program A Final Word on Packages Summary 536 536 543 544 5 51 552 552 552 554 556 557 558 558 558 559 559 559 560 560 560 560 560 560 560 5 61 5 61 5 61 5 61 5 61 xxix 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xxx Contents Chapter 19 : Pla ying Administrator Scheduling Jobs Creating an Operator... Message ID/Message String Severity State Error Arguments WITH Adding Your Own Custom Error Messages @lang xxiv 359 360 3 61 3 61 3 61 364 365 367 368 368 369 370 370 370 372 373 376 376 378 379 379 380 3 81 384 390 390 390 3 91 3 91 393 393 394 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xxv Contents @with_log @replace Using sp_addmessage Removing an Existing Custom Message What a Sproc Offer s Creating... Not to Roll Back Within Triggers Dropping Triggers Debugging Triggers Summary 453 454 454 456 456 457 457 457 457 459 4 61 4 61 462 462 462 463 463 464 465 465 465 466 466 466 467 467 468 469 469 470 470 470 4 71 xxvii 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xxviii Contents Chapter 16 : A Brief XML Primer XML Basics Parts of an XML Document The Document Declaration Elements Nodes Attributes No Defects . dbo 11 5 The Database Name 11 6 Naming by Server 11 6 Reviewing the Defaults 11 7 57 012 ftoc.qxd:WroxBeg 11 /22/08 10 :18 AM Page xvii xviii Contents The CREATE Statement 11 7 CREATE DATABASE 11 7 ON 11 8 NAME. 11 8 NAME 11 9 FILENAME 11 9 SIZE 11 9 MAXSIZE 11 9 FILEGROWTH 12 0 LOG ON 12 0 COLLATE 12 0 FOR ATTACH 12 0 WITH DB CHAINING ON|OFF 12 1 TRUSTWORTHY 12 1 Building a Database 12 1 CREATE TABLE 12 3 Table. 9 Stored Procedures 10 User-Defined Functions 10 Users and Roles 11 Rules 11 Defaults 11 User-Defined Data Types 11 Full-Text Catalogs 12 SQL Ser ver Data T ypes 12 NULL Data 18 SQL Ser ver Identifiers