| Foreword |
|
xi | (2) |
| Preface |
|
xiii | |
| I. The Basics: Programming in Transact-SQL |
|
1 | (174) |
|
1. Introduction to Transact-SQL |
|
|
3 | (25) |
|
SQL and the Introduction of Transact-SQL |
|
|
3 | (1) |
|
The Relational Database Model |
|
|
4 | (2) |
|
|
|
6 | (7) |
|
Row Processing Versus Set Processing |
|
|
13 | (1) |
|
The History of SQL Server |
|
|
14 | (2) |
|
|
|
16 | (10) |
|
|
|
26 | (2) |
|
2. Database Analysis and Design |
|
|
28 | (23) |
|
The Need for Adequate Analysis and Design |
|
|
28 | (1) |
|
|
|
29 | (2) |
|
|
|
31 | (3) |
|
|
|
34 | (4) |
|
Putting it Together with CASE Technology |
|
|
38 | (11) |
|
|
|
49 | (2) |
|
|
|
51 | (69) |
|
|
|
51 | (1) |
|
|
|
52 | (24) |
|
Data Manipulation Language |
|
|
76 | (43) |
|
|
|
119 | (1) |
|
4. Transact-SQL Fundamentals |
|
|
120 | (27) |
|
|
|
120 | (1) |
|
|
|
121 | (4) |
|
|
|
125 | (2) |
|
|
|
127 | (9) |
|
|
|
136 | (7) |
|
|
|
143 | (1) |
|
|
|
144 | (2) |
|
|
|
146 | (1) |
|
|
|
147 | (28) |
|
|
|
147 | (2) |
|
What Is a Good Coding Style? |
|
|
149 | (4) |
|
Case of Keywords and User-Defined Names |
|
|
153 | (2) |
|
Naming Conventions and Abbreviations |
|
|
155 | (5) |
|
|
|
160 | (1) |
|
|
|
161 | (3) |
|
Formatting DML and DDL Statements |
|
|
164 | (4) |
|
Formatting Transaction Blocks and Procedural Blocks |
|
|
168 | (3) |
|
|
|
171 | (2) |
|
|
|
173 | (2) |
| II. The Building Blocks: Transact-SQL Language Elements |
|
175 | (172) |
|
6. Datatypes and Variables |
|
|
177 | (32) |
|
|
|
177 | (12) |
|
|
|
189 | (2) |
|
|
|
191 | (1) |
|
|
|
192 | (11) |
|
|
|
203 | (5) |
|
|
|
208 | (1) |
|
7. Conditional Processing |
|
|
209 | (21) |
|
|
|
210 | (1) |
|
|
|
211 | (7) |
|
GOTO Branching and Error Handling |
|
|
218 | (1) |
|
|
|
219 | (3) |
|
|
|
222 | (5) |
|
|
|
227 | (2) |
|
|
|
229 | (1) |
|
8. Row Processing with Cursors |
|
|
230 | (26) |
|
|
|
231 | (1) |
|
|
|
232 | (2) |
|
|
|
234 | (1) |
|
|
|
235 | (2) |
|
|
|
237 | (4) |
|
Closing and Deallocating a Cursor |
|
|
241 | (1) |
|
|
|
242 | (5) |
|
Performance Issues for Cursors |
|
|
247 | (7) |
|
|
|
254 | (2) |
|
|
|
256 | (18) |
|
Code Processing and Error Handling: Basic Concepts |
|
|
256 | (1) |
|
Displaying an Error Message with PRINT |
|
|
257 | (2) |
|
Raising an Error with RAISERROR |
|
|
259 | (9) |
|
Finding Error Conditions with Global Variables |
|
|
268 | (1) |
|
Handling Errors with GOTO |
|
|
269 | (1) |
|
Creating Specialized Error Messages |
|
|
270 | (1) |
|
Finding Error Messages in Operating System Files |
|
|
271 | (1) |
|
|
|
272 | (2) |
|
|
|
274 | (23) |
|
Creating and Manipulating Temporary Objects |
|
|
275 | (1) |
|
|
|
276 | (1) |
|
Classes of Temporary Objects |
|
|
277 | (15) |
|
Query Optimization with Temporary Tables |
|
|
292 | (1) |
|
Management of the tempdb Database |
|
|
293 | (2) |
|
|
|
295 | (2) |
|
11. Transactions and Locking |
|
|
297 | (50) |
|
|
|
298 | (11) |
|
|
|
309 | (24) |
|
Transactions and the Database |
|
|
333 | (13) |
|
|
|
346 | (1) |
| III. Functions and Extensions |
|
347 | (88) |
|
|
|
349 | (65) |
|
|
|
353 | (6) |
|
|
|
359 | (7) |
|
|
|
366 | (15) |
|
|
|
381 | (4) |
|
|
|
385 | (1) |
|
Type Conversion Functions |
|
|
386 | (10) |
|
|
|
396 | (16) |
|
|
|
412 | (2) |
|
13. CASE Expressions and Transact-SQL Extensions |
|
|
414 | (21) |
|
|
|
414 | (7) |
|
|
|
421 | (3) |
|
|
|
424 | (10) |
|
|
|
434 | (1) |
| IV. Programming Transact-SQL Objects |
|
435 | (132) |
|
14. Stored Procedures and Modular Design |
|
|
437 | (52) |
|
|
|
438 | (1) |
|
|
|
439 | (11) |
|
Types of Stored Procedures |
|
|
450 | (4) |
|
Advantages of Stored Procedures |
|
|
454 | (1) |
|
Stored Procedures Versus Other Objects |
|
|
454 | (2) |
|
Executing Stored Procedures |
|
|
456 | (3) |
|
Remote Procedure Calls (RPCs) |
|
|
459 | (6) |
|
|
|
465 | (5) |
|
Conditional Data Retrieval |
|
|
470 | (2) |
|
|
|
472 | (4) |
|
Data Security and Encryption |
|
|
476 | (8) |
|
|
|
484 | (4) |
|
|
|
488 | (1) |
|
15. Triggers and Constraints |
|
|
489 | (14) |
|
|
|
489 | (11) |
|
Interaction of Triggers and Constraints |
|
|
500 | (2) |
|
|
|
502 | (1) |
|
|
|
503 | (24) |
|
|
|
503 | (1) |
|
|
|
504 | (5) |
|
|
|
509 | (11) |
|
View Dependencies, Permissions, and Data Manipulations |
|
|
520 | (4) |
|
|
|
524 | (1) |
|
|
|
525 | (1) |
|
|
|
526 | (1) |
|
17. System and Extended Stored Procedures |
|
|
527 | (40) |
|
|
|
527 | (1) |
|
Common System Stored Procedures |
|
|
528 | (30) |
|
Extended Stored Procedures |
|
|
558 | (8) |
|
|
|
566 | (1) |
| V. Performance Tuning and Optimization |
|
567 | (152) |
|
18. Transact-SQL Code Design |
|
|
569 | (17) |
|
|
|
569 | (2) |
|
|
|
571 | (3) |
|
|
|
574 | (4) |
|
|
|
578 | (1) |
|
|
|
578 | (1) |
|
|
|
578 | (4) |
|
Using Parameters Effectively |
|
|
582 | (1) |
|
|
|
583 | (2) |
|
|
|
585 | (1) |
|
19. Code Maintenance in SQL Server |
|
|
586 | (18) |
|
Using SQL Server System Tables |
|
|
586 | (3) |
|
Interdependence of Server-Side Objects |
|
|
589 | (1) |
|
|
|
590 | (8) |
|
|
|
598 | (4) |
|
|
|
602 | (1) |
|
|
|
603 | (1) |
|
20. Transact-SQL Optimization and Tuning |
|
|
604 | (68) |
|
|
|
605 | (3) |
|
Efficient Physical Database Design |
|
|
608 | (4) |
|
|
|
612 | (7) |
|
SQL Server Query Optimizer |
|
|
619 | (6) |
|
|
|
625 | (7) |
|
|
|
632 | (6) |
|
|
|
638 | (14) |
|
Optimization Tips and Techniques |
|
|
652 | (18) |
|
|
|
670 | (2) |
|
21. Debugging Transact-SQL Programs |
|
|
672 | (47) |
|
|
|
672 | (1) |
|
|
|
673 | (7) |
|
Specific Debugging Techniques |
|
|
680 | (25) |
|
|
|
705 | (11) |
|
|
|
716 | (1) |
|
|
|
717 | (2) |
| VI. Appendixes |
|
719 | (70) |
|
|
|
721 | (22) |
|
B. What's New for Transact-SQL in Microsoft SQL Server 7.0 |
|
|
743 | (36) |
|
|
|
779 | (10) |
| Index |
|
789 | |