Foreword |
|
xxiii | |
Preface |
|
xxv | |
Preface to the First Edition |
|
xxix | |
PART I: OVERVIEW |
|
|
The Evolution of Microsoft SQL Server: 1989 to 1999 |
|
|
3 | (28) |
|
|
6 | (1) |
|
|
7 | (1) |
|
Microsoft SQL Server Ships |
|
|
8 | (2) |
|
|
10 | (2) |
|
|
12 | (1) |
|
|
13 | (3) |
|
|
14 | (1) |
|
|
15 | (1) |
|
SQL Server for Windows NT |
|
|
16 | (5) |
|
Success Brings Fundamental Change |
|
|
21 | (2) |
|
The End of Joint Development |
|
|
23 | (2) |
|
|
25 | (2) |
|
|
27 | (1) |
|
|
28 | (2) |
|
|
30 | (1) |
|
|
31 | (44) |
|
|
32 | (6) |
|
|
33 | (5) |
|
DBMS-Enforced Data Integrity |
|
|
38 | (5) |
|
Declarative Data Integrity |
|
|
38 | (2) |
|
|
40 | (1) |
|
CHECK Constraints and Rules |
|
|
40 | (1) |
|
|
41 | (1) |
|
|
41 | (2) |
|
|
43 | (2) |
|
|
43 | (1) |
|
|
44 | (1) |
|
|
44 | (1) |
|
|
44 | (1) |
|
Symmetric Server Architecture |
|
|
45 | (2) |
|
Traditional Process/Thread Model |
|
|
45 | (1) |
|
SQL Server Process/Thread Model |
|
|
46 | (1) |
|
|
47 | (1) |
|
|
47 | (2) |
|
Monitoring and Managing Security |
|
|
48 | (1) |
|
|
49 | (1) |
|
Distributed Data Processing |
|
|
50 | (1) |
|
|
51 | (3) |
|
|
54 | (7) |
|
SQL Server Enterprise Manager |
|
|
54 | (2) |
|
Distributed Management Objects |
|
|
56 | (2) |
|
Automation and Visual Basic Scripting |
|
|
58 | (1) |
|
|
59 | (2) |
|
SQL Server Utilities and Extensions |
|
|
61 | (7) |
|
Web Assistant Wizard and Internet Enabling |
|
|
61 | (2) |
|
|
63 | (1) |
|
SQL Server Service Manager |
|
|
63 | (1) |
|
Windows NT Performance Monitor Integration |
|
|
64 | (1) |
|
|
64 | (1) |
|
|
65 | (1) |
|
|
65 | (1) |
|
|
66 | (1) |
|
SQL Server Query Analyzer |
|
|
67 | (1) |
|
Bulk Copy and Data Transformation Services |
|
|
67 | (1) |
|
|
67 | (1) |
|
|
68 | (1) |
|
Client Development Interfaces |
|
|
68 | (3) |
|
|
69 | (1) |
|
|
69 | (1) |
|
|
69 | (1) |
|
|
69 | (1) |
|
|
70 | (1) |
|
|
70 | (1) |
|
Server Development Interface |
|
|
70 | (1) |
|
|
71 | (4) |
PART II: ARCHITECTURAL OVERVIEW |
|
|
|
75 | (46) |
|
|
75 | (24) |
|
|
75 | (3) |
|
|
78 | (5) |
|
The Relational Engine and the Storage Engine |
|
|
83 | (5) |
|
The Access Methods Manager |
|
|
88 | (1) |
|
The Row Operations Manager and the Index Manager |
|
|
88 | (5) |
|
The Page Manager and the Text Manager |
|
|
93 | (1) |
|
|
94 | (4) |
|
|
98 | (1) |
|
|
98 | (1) |
|
|
99 | (8) |
|
The Buffer Manager and Memory Pools |
|
|
99 | (1) |
|
Access to In-Memory Pages |
|
|
99 | (1) |
|
Access to Free Pages (lazywriter) |
|
|
100 | (2) |
|
|
102 | (2) |
|
Accessing Pages via the Buffer Manager |
|
|
104 | (1) |
|
|
104 | (2) |
|
|
106 | (1) |
|
Transaction Logging and Recovery |
|
|
107 | (5) |
|
|
110 | (1) |
|
|
110 | (2) |
|
The SQL Server Kernel and Interaction with the Operationg System |
|
|
112 | (6) |
|
Threading and Symmetric Multiprocessing |
|
|
113 | (2) |
|
|
115 | (2) |
|
|
117 | (1) |
|
|
118 | (3) |
PART III: USING MICROSOFT SQL SERVER |
|
|
Planning for and Installing SQL Server |
|
|
121 | (58) |
|
|
121 | (3) |
|
|
123 | (1) |
|
|
124 | (1) |
|
|
124 | (4) |
|
Use Hardware on the Windows Hardware Compatibility List |
|
|
124 | (1) |
|
|
125 | (1) |
|
Performance = Fn(Processor Cycles, Memory, I/O Throughput) |
|
|
126 | (1) |
|
|
127 | (1) |
|
|
128 | (22) |
|
|
128 | (2) |
|
|
130 | (2) |
|
Disk Drives, Controllers, and Disk Arrays |
|
|
132 | (2) |
|
|
134 | (10) |
|
More About Drives and Controllers |
|
|
144 | (2) |
|
Uninteruptible Power Supply |
|
|
146 | (1) |
|
|
147 | (1) |
|
Fallback Server Capability |
|
|
148 | (1) |
|
Other Hardware Considerations |
|
|
149 | (1) |
|
|
150 | (1) |
|
|
151 | (1) |
|
Security and the User Context |
|
|
152 | (2) |
|
|
154 | (5) |
|
|
155 | (1) |
|
|
156 | (1) |
|
|
157 | (2) |
|
|
159 | (4) |
|
Character Sets and Sort Orders |
|
|
163 | (8) |
|
|
163 | (3) |
|
|
166 | (5) |
|
|
171 | (1) |
|
Basic Configuration After Installation |
|
|
172 | (2) |
|
Starting the SQL Server Service |
|
|
172 | (1) |
|
Changing the System Administrator Password |
|
|
172 | (1) |
|
Configuring SQL Server's Error Log |
|
|
173 | (1) |
|
Remote and Unattended Installation |
|
|
174 | (4) |
|
|
174 | (1) |
|
|
175 | (1) |
|
Changing Installation Options |
|
|
176 | (1) |
|
Adding Additional Components |
|
|
177 | (1) |
|
|
178 | (1) |
|
Databases and Database Files |
|
|
179 | (34) |
|
|
180 | (2) |
|
|
180 | (1) |
|
|
181 | (1) |
|
|
181 | (1) |
|
|
181 | (1) |
|
|
182 | (1) |
|
|
182 | (1) |
|
|
182 | (2) |
|
|
184 | (2) |
|
|
186 | (1) |
|
Expanding and Shrinking Databases |
|
|
186 | (3) |
|
|
187 | (1) |
|
|
187 | (1) |
|
|
187 | (1) |
|
|
187 | (2) |
|
|
189 | (4) |
|
|
193 | (3) |
|
FILEGROUP CREATION Example |
|
|
195 | (1) |
|
|
196 | (2) |
|
|
197 | (1) |
|
|
198 | (5) |
|
|
201 | (2) |
|
|
203 | (7) |
|
Changing Database Options |
|
|
209 | (1) |
|
Other Database Considerations |
|
|
210 | (2) |
|
Database Doesn't Equal Schema |
|
|
210 | (1) |
|
|
210 | (1) |
|
|
211 | (1) |
|
|
212 | (1) |
|
|
213 | (86) |
|
|
214 | (15) |
|
Naming Tables and Columns |
|
|
215 | (1) |
|
|
215 | (1) |
|
|
216 | (2) |
|
|
218 | (1) |
|
|
219 | (6) |
|
|
225 | (4) |
|
Internal Storage---The Details |
|
|
229 | (17) |
|
|
231 | (2) |
|
|
233 | (3) |
|
|
236 | (2) |
|
|
238 | (1) |
|
Storage of Fixed-Length and Variable-Length Rows |
|
|
239 | (4) |
|
|
243 | (1) |
|
|
244 | (2) |
|
|
246 | (4) |
|
|
247 | (1) |
|
|
247 | (1) |
|
|
248 | (1) |
|
|
248 | (2) |
|
|
250 | (1) |
|
|
251 | (4) |
|
|
255 | (37) |
|
PRIMARY KEY and UNIQUE Constraints |
|
|
255 | (6) |
|
|
261 | (8) |
|
Constraint Checking Solutions |
|
|
269 | (2) |
|
Restrictions on Dropping Tables |
|
|
271 | (1) |
|
|
271 | (2) |
|
|
273 | (2) |
|
|
275 | (4) |
|
|
279 | (5) |
|
|
284 | (8) |
|
|
292 | (3) |
|
|
292 | (1) |
|
|
293 | (1) |
|
Adding, Dropping, Disabling, or Enabling a Constraint |
|
|
294 | (1) |
|
|
294 | (1) |
|
Enabling or Disabling a Trigger |
|
|
295 | (1) |
|
|
295 | (3) |
|
Private Temporary Tables (#) |
|
|
296 | (1) |
|
Global Temporary Tables (##) |
|
|
296 | (1) |
|
|
297 | (1) |
|
Constraints on Temporary Tables |
|
|
297 | (1) |
|
|
298 | (1) |
|
|
299 | (92) |
|
|
299 | (3) |
|
|
302 | (20) |
|
|
307 | (6) |
|
The Obsolete *= OUTER JOIN Operator |
|
|
313 | (7) |
|
|
320 | (2) |
|
|
322 | (10) |
|
|
325 | (4) |
|
|
329 | (3) |
|
|
332 | (13) |
|
|
337 | (8) |
|
|
345 | (5) |
|
|
349 | (1) |
|
|
350 | (39) |
|
|
350 | (7) |
|
|
357 | (1) |
|
|
357 | (7) |
|
Datacube---Aggregate Variations |
|
|
364 | (16) |
|
|
380 | (3) |
|
|
383 | (6) |
|
|
389 | (2) |
|
|
391 | (52) |
|
Basic Modification Operations |
|
|
391 | (30) |
|
|
391 | (15) |
|
|
406 | (3) |
|
|
409 | (2) |
|
Modifying Data Through Views |
|
|
411 | (10) |
|
Data Modification Internals |
|
|
421 | (20) |
|
|
421 | (1) |
|
|
422 | (4) |
|
|
426 | (6) |
|
|
432 | (6) |
|
Table-Level vs. Index-Level Data Modification |
|
|
438 | (2) |
|
|
440 | (1) |
|
|
440 | (1) |
|
|
441 | (2) |
|
Programming with Transact-SQL |
|
|
443 | (64) |
|
Transact-SQL as a Programming Language |
|
|
443 | (4) |
|
Programming at Multiple Levels |
|
|
445 | (2) |
|
Transact-SQL Programming Constructs---The Basics |
|
|
447 | (59) |
|
|
447 | (4) |
|
|
451 | (1) |
|
|
452 | (4) |
|
|
456 | (2) |
|
|
458 | (2) |
|
|
460 | (1) |
|
|
461 | (7) |
|
|
468 | (38) |
|
|
506 | (1) |
|
Batches, Transactions, Stored Procedures, and Triggers |
|
|
507 | (100) |
|
|
507 | (5) |
|
|
512 | (21) |
|
Explicit and Implicit Transactions |
|
|
513 | (1) |
|
Error Checking in Transactions |
|
|
514 | (6) |
|
Transaction Isolation Levels |
|
|
520 | (12) |
|
Additional Characteristics of Transactions |
|
|
532 | (1) |
|
|
533 | (15) |
|
|
535 | (1) |
|
Recursion in Stored Procedures |
|
|
536 | (5) |
|
Nested Transaction Blocks |
|
|
541 | (5) |
|
|
546 | (1) |
|
Stored Procedure Parameters |
|
|
547 | (1) |
|
Executing Batches, or What's Stored About a Stored Procedure? |
|
|
548 | (27) |
|
Step One: Parse Commands and Create the Sequence Tree |
|
|
548 | (1) |
|
Step Two: Compile the Batch |
|
|
548 | (1) |
|
|
548 | (2) |
|
Step Four: Recompile Execution Plans |
|
|
550 | (2) |
|
Storage of Stored Procedures |
|
|
552 | (1) |
|
Encrypting Stored Procedures |
|
|
553 | (3) |
|
Altering a Stored Procedure |
|
|
556 | (1) |
|
Temporary Stored Procedures |
|
|
556 | (3) |
|
System Stored Procedures and the Special sp_Prefix |
|
|
559 | (2) |
|
Autostart Stored Procedures |
|
|
561 | (1) |
|
|
562 | (2) |
|
Catalog Stored Procedures |
|
|
564 | (1) |
|
SQL Server Agent Stored Procedures |
|
|
565 | (1) |
|
Replication Stored Procedures |
|
|
566 | (2) |
|
Extended Stored Procedures |
|
|
568 | (7) |
|
|
575 | (5) |
|
|
578 | (2) |
|
Debugging Stored Procedures and Triggers |
|
|
580 | (4) |
|
|
584 | (1) |
|
Working with Text and Image Data |
|
|
584 | (14) |
|
|
586 | (3) |
|
|
589 | (4) |
|
|
593 | (5) |
|
|
598 | (8) |
|
|
598 | (2) |
|
Nullability and ANSI Compliance Settings |
|
|
600 | (5) |
|
Locale-Specific SET Options |
|
|
605 | (1) |
|
|
606 | (1) |
|
|
607 | (54) |
|
|
608 | (2) |
|
|
610 | (5) |
|
Problems with ISAM-Style Applications |
|
|
614 | (1) |
|
|
615 | (6) |
|
|
616 | (1) |
|
|
616 | (1) |
|
|
617 | (2) |
|
|
619 | (1) |
|
API Server Cursors vs. Transact-SQL Cursors |
|
|
619 | (2) |
|
Appropriate Use of Cursors |
|
|
621 | (11) |
|
|
621 | (1) |
|
|
622 | (1) |
|
|
623 | (1) |
|
|
624 | (1) |
|
Cursor Membership, Scrolling, and Sensitivity to Change |
|
|
625 | (7) |
|
Working with Transact-SQL Cursors |
|
|
632 | (20) |
|
|
632 | (2) |
|
|
634 | (2) |
|
|
636 | (2) |
|
|
638 | (1) |
|
|
638 | (1) |
|
|
638 | (1) |
|
|
639 | (1) |
|
|
640 | (1) |
|
Fully Scrollable Transact-SQL Cursors |
|
|
640 | (3) |
|
Concurrency Control with Transact-SQL Cursors |
|
|
643 | (9) |
|
|
652 | (8) |
|
Obtaining Cursor Information |
|
|
653 | (7) |
|
|
660 | (1) |
|
Transact-SQL Examples and Brainteasers |
|
|
661 | (66) |
|
Using Triggers to Implement Referential Actions |
|
|
661 | (9) |
|
|
669 | (1) |
|
|
670 | (56) |
|
|
671 | (5) |
|
|
676 | (11) |
|
Finding Differences Between Intervals |
|
|
687 | (6) |
|
|
693 | (1) |
|
|
694 | (1) |
|
Finding Rows with Matching Columns |
|
|
694 | (5) |
|
Putting Data on a Web Page |
|
|
699 | (1) |
|
|
699 | (7) |
|
Selecting Instead of Iterating |
|
|
706 | (1) |
|
Getting a Row Count of a Table |
|
|
707 | (1) |
|
|
708 | (1) |
|
Using Pivot Tables (Cross-Tabs) |
|
|
709 | (4) |
|
Integrating SQL Server with E-Mail |
|
|
713 | (6) |
|
Copying Text to Sequenced varchar Columns |
|
|
719 | (4) |
|
Instantiating and Executing an Automation Object |
|
|
723 | (3) |
|
|
726 | (1) |
|
|
727 | (32) |
|
|
727 | (7) |
|
The Lock Manager and Isolation Levels |
|
|
728 | (1) |
|
|
729 | (1) |
|
|
729 | (5) |
|
|
734 | (1) |
|
|
734 | (14) |
|
|
735 | (3) |
|
|
738 | (4) |
|
|
742 | (1) |
|
|
742 | (1) |
|
|
742 | (6) |
|
|
748 | (2) |
|
|
750 | (2) |
|
Row-Level vs. Page-Level Locking |
|
|
752 | (2) |
|
|
753 | (1) |
|
Locking Hints and Trace Flags |
|
|
754 | (1) |
|
|
755 | (4) |
PART IV: PERFORMANCE AND TUNING |
|
|
Optimizing Query Performance |
|
|
759 | (90) |
|
|
760 | (1) |
|
Application and Database Desing |
|
|
760 | (6) |
|
|
761 | (2) |
|
Evaluate Your Critical Transactions |
|
|
763 | (2) |
|
Keep Table Row Lengths and Keys Compact |
|
|
765 | (1) |
|
|
766 | (1) |
|
Perceived Response Time for Interactive Systems |
|
|
766 | (2) |
|
Prototyping, Benchmarking, and Testing |
|
|
768 | (4) |
|
A Rant on Development Methodologies |
|
|
771 | (1) |
|
|
772 | (8) |
|
Choose the Clustered Index Carefully |
|
|
774 | (1) |
|
Make Nonclustered Indexes Highly Selective |
|
|
775 | (1) |
|
Tailor Indexes to Critical Transactions |
|
|
776 | (2) |
|
Pay Attention to Column Order |
|
|
778 | (1) |
|
Index Columns Used in Joins |
|
|
778 | (1) |
|
Create or Drop Indexes as Needed |
|
|
779 | (1) |
|
Using Stored Procedures and Caching Mechanisms |
|
|
780 | (8) |
|
|
781 | (1) |
|
|
782 | (1) |
|
The sp_executesql Procedure |
|
|
782 | (1) |
|
The Prepare and Execute Method |
|
|
783 | (1) |
|
|
783 | (1) |
|
When to Use Stored Procedures and Other Caching Mechanisms |
|
|
784 | (1) |
|
Recompiling Stored Procedures |
|
|
784 | (1) |
|
Limiting the Number of Plans in Cache |
|
|
785 | (1) |
|
Other Benefits of Stored Procedures |
|
|
786 | (2) |
|
Concurrency and Consistency Tradeoffs |
|
|
788 | (1) |
|
Resolving Blocking Problems |
|
|
789 | (5) |
|
|
791 | (3) |
|
Resolving Deadlock Problems |
|
|
794 | (13) |
|
|
794 | (1) |
|
Conversion Deadlock Example |
|
|
795 | (2) |
|
|
797 | (1) |
|
|
797 | (1) |
|
Volunteering to Be the Deadlock Victim |
|
|
798 | (1) |
|
Watching Locking Activity |
|
|
799 | (1) |
|
|
799 | (8) |
|
Segregating OLTP and DSS Applications |
|
|
807 | (1) |
|
|
807 | (28) |
|
|
809 | (2) |
|
|
811 | (12) |
|
|
823 | (5) |
|
Other Processing Strategies |
|
|
828 | (2) |
|
|
830 | (3) |
|
|
833 | (2) |
|
Monitoring Query Performance |
|
|
835 | (13) |
|
|
835 | (2) |
|
|
837 | (1) |
|
|
838 | (2) |
|
|
840 | (8) |
|
|
848 | (1) |
|
Configuration and Performance Monitoring |
|
|
849 | (42) |
|
Windows NT Configuration Settings |
|
|
849 | (3) |
|
|
850 | (1) |
|
|
850 | (1) |
|
|
851 | (1) |
|
|
851 | (1) |
|
|
851 | (1) |
|
|
851 | (1) |
|
SQL Server Configuration Settings |
|
|
852 | (15) |
|
|
852 | (12) |
|
|
864 | (1) |
|
|
865 | (1) |
|
Startup Parameters on SQLSERVR.EXE |
|
|
866 | (1) |
|
|
867 | (1) |
|
Monitoring System Behavior |
|
|
868 | (22) |
|
|
868 | (11) |
|
|
879 | (11) |
|
Other Performance Monitoring Considerations |
|
|
890 | (1) |
|
|
890 | (1) |
Suggested Reading |
|
891 | (6) |
Index |
|
897 | |