| About the Author |
|
xvii | |
| About the Technical Reviewer |
|
xix | |
| Acknowledgments |
|
xxi | |
| Introduction |
|
xxiii | |
|
SQL Server 2005 Overview and Installation |
|
|
1 | (24) |
|
|
|
2 | (1) |
|
|
|
3 | (1) |
|
|
|
4 | (2) |
|
|
|
4 | (1) |
|
|
|
5 | (1) |
|
|
|
5 | (1) |
|
Operating System Requirements |
|
|
5 | (1) |
|
|
|
6 | (1) |
|
|
|
6 | (1) |
|
|
|
6 | (12) |
|
|
|
7 | (11) |
|
|
|
18 | (5) |
|
|
|
18 | (1) |
|
Looking at the Authentication Mode |
|
|
18 | (4) |
|
|
|
22 | (1) |
|
|
|
23 | (2) |
|
SQL Server Management Studio |
|
|
25 | (28) |
|
|
|
25 | (9) |
|
|
|
34 | (11) |
|
|
|
34 | (3) |
|
|
|
37 | (1) |
|
|
|
38 | (2) |
|
|
|
40 | (2) |
|
|
|
42 | (3) |
|
|
|
45 | (2) |
|
Surface Area Configuration Tool |
|
|
47 | (4) |
|
|
|
51 | (2) |
|
Database Design and Creation |
|
|
53 | (42) |
|
|
|
54 | (1) |
|
Databases Within SQL Server |
|
|
55 | (3) |
|
|
|
56 | (1) |
|
|
|
56 | (1) |
|
|
|
57 | (1) |
|
|
|
58 | (1) |
|
AdventureWorks/AdventureWorksDW |
|
|
58 | (1) |
|
Choosing the Database System Type |
|
|
58 | (2) |
|
|
|
58 | (1) |
|
|
|
59 | (1) |
|
|
|
60 | (1) |
|
|
|
60 | (2) |
|
Determining the Information to Store in the Database |
|
|
62 | (3) |
|
|
|
63 | (1) |
|
|
|
64 | (1) |
|
|
|
64 | (1) |
|
|
|
64 | (1) |
|
|
|
64 | (1) |
|
External and Ignored Information |
|
|
65 | (1) |
|
|
|
65 | (6) |
|
|
|
65 | (2) |
|
|
|
67 | (3) |
|
|
|
70 | (1) |
|
|
|
71 | (5) |
|
Each Entity Should Have a Unique Identifier |
|
|
73 | (1) |
|
Only Store Information That Directly Relates to That Entity |
|
|
73 | (1) |
|
Avoid Repeating Values or Columns |
|
|
73 | (1) |
|
|
|
73 | (2) |
|
|
|
75 | (1) |
|
Creating the Sample Database |
|
|
76 | (18) |
|
Creating a Database in SQL Server Management Studio |
|
|
76 | (13) |
|
Dropping the Database in SQL Server Management Studio |
|
|
89 | (3) |
|
Creating a Database in a Query Pane |
|
|
92 | (2) |
|
|
|
94 | (1) |
|
|
|
95 | (24) |
|
|
|
95 | (10) |
|
Server Logins and Database Users |
|
|
105 | (1) |
|
|
|
105 | (6) |
|
|
|
105 | (2) |
|
|
|
107 | (1) |
|
|
|
108 | (3) |
|
|
|
111 | (2) |
|
Before You Can Proceed with Your Solution |
|
|
113 | (4) |
|
|
|
117 | (2) |
|
|
|
119 | (34) |
|
|
|
120 | (1) |
|
Defining a Table: SQL Server Management Studio |
|
|
121 | (5) |
|
Different Table Data Types |
|
|
121 | (4) |
|
Different Program Data Types |
|
|
125 | (1) |
|
Columns Are More Than Simple Data Repositories |
|
|
126 | (1) |
|
|
|
126 | (1) |
|
Generating Identity Values |
|
|
126 | (1) |
|
|
|
127 | (1) |
|
Why Define a Column to Allow NULL? |
|
|
127 | (1) |
|
Image and Large Text Storage in SQL Server |
|
|
127 | (1) |
|
Creating a Table in SQL Server Management Studio |
|
|
128 | (6) |
|
Defining a Table Through the Query Editor |
|
|
134 | (2) |
|
Defining a Table: Using a Template |
|
|
136 | (3) |
|
Creating and Altering a Template |
|
|
139 | (2) |
|
|
|
141 | (1) |
|
Defining the Remaining Tables |
|
|
142 | (1) |
|
|
|
143 | (1) |
|
|
|
144 | (6) |
|
Check Existing Data on Creation |
|
|
148 | (1) |
|
Enforce Foreign Key Constraints |
|
|
149 | (1) |
|
|
|
149 | (1) |
|
Using the Alter Table SQL Statement |
|
|
150 | (1) |
|
|
|
151 | (2) |
|
Creating Indexes and Database Diagramming |
|
|
153 | (32) |
|
|
|
153 | (3) |
|
|
|
154 | (2) |
|
|
|
156 | (1) |
|
Determining What Makes a Good Index |
|
|
156 | (3) |
|
Using Low-Maintenance Columns |
|
|
156 | (1) |
|
|
|
157 | (1) |
|
|
|
157 | (1) |
|
|
|
157 | (1) |
|
Looking for a Range of Information |
|
|
158 | (1) |
|
Keeping the Data in Order |
|
|
158 | (1) |
|
Determining What Makes a Bad Index |
|
|
159 | (1) |
|
|
|
159 | (1) |
|
|
|
159 | (1) |
|
Including Too Many Columns |
|
|
159 | (1) |
|
Including Too Few Records in the Table |
|
|
159 | (1) |
|
Reviewing Your Indexes for Performance |
|
|
160 | (1) |
|
|
|
160 | (13) |
|
Creating an Index with the Table Designer |
|
|
161 | (2) |
|
|
|
163 | (1) |
|
|
|
164 | (2) |
|
Creating an Index in Query Editor: Template |
|
|
166 | (4) |
|
Creating an Index in Query Editor: SQL Code |
|
|
170 | (3) |
|
|
|
173 | (1) |
|
Altering an Index in Query Editor |
|
|
174 | (2) |
|
|
|
176 | (7) |
|
Database Diagramming Basics |
|
|
176 | (1) |
|
The SQL Server Database Diagram Tool |
|
|
177 | (1) |
|
The Default Database Diagram |
|
|
178 | (2) |
|
The Database Diagram Toolbar |
|
|
180 | (3) |
|
|
|
183 | (2) |
|
Database Backups, Recovery, and Maintenance |
|
|
185 | (60) |
|
|
|
186 | (2) |
|
|
|
188 | (1) |
|
|
|
189 | (1) |
|
Taking a Database Offline |
|
|
190 | (1) |
|
|
|
191 | (16) |
|
Backing Up the Database Using T-SQL |
|
|
196 | (8) |
|
Transaction Log Backup Using T-SQL |
|
|
204 | (3) |
|
|
|
207 | (7) |
|
Restoring Using SQL Server Management Studio |
|
|
207 | (3) |
|
|
|
210 | (4) |
|
Detaching and Attaching a Database |
|
|
214 | (8) |
|
Detaching and Attaching Using SQL Server Management Studio |
|
|
215 | (5) |
|
Detaching and Attaching Using T-SQL |
|
|
220 | (2) |
|
Producing SQL Script for the Database |
|
|
222 | (8) |
|
Maintaining Your Database |
|
|
230 | (1) |
|
Creating a Database Maintenance Plan |
|
|
230 | (13) |
|
|
|
243 | (2) |
|
|
|
245 | (64) |
|
The T-SQL Insert Command Syntax |
|
|
246 | (1) |
|
|
|
247 | (7) |
|
|
|
249 | (1) |
|
|
|
249 | (5) |
|
|
|
254 | (1) |
|
|
|
255 | (7) |
|
|
|
256 | (6) |
|
Dealing with Several Records at Once |
|
|
262 | (1) |
|
Inserting Several Records in a Query Batch |
|
|
262 | (1) |
|
|
|
263 | (1) |
|
Using SQL Server Management Studio to Retrieve Data |
|
|
264 | (2) |
|
|
|
266 | (2) |
|
|
|
268 | (1) |
|
|
|
269 | (2) |
|
Varying the Output Display |
|
|
271 | (2) |
|
Limiting the Search: The Use of Where |
|
|
273 | (5) |
|
|
|
276 | (1) |
|
|
|
277 | (1) |
|
|
|
278 | (1) |
|
|
|
278 | (2) |
|
|
|
280 | (2) |
|
|
|
282 | (2) |
|
Creating Data: SELECT INTO |
|
|
284 | (2) |
|
Who Can Add, Delete, and Select Data |
|
|
286 | (5) |
|
|
|
291 | (1) |
|
|
|
291 | (5) |
|
|
|
292 | (1) |
|
Updating Data Within Query Editor |
|
|
293 | (3) |
|
|
|
296 | (7) |
|
|
|
298 | (1) |
|
|
|
298 | (1) |
|
|
|
298 | (1) |
|
|
|
299 | (1) |
|
Updating Data: Using Transactions |
|
|
299 | (2) |
|
|
|
301 | (2) |
|
|
|
303 | (3) |
|
|
|
303 | (1) |
|
Using the Delete Statement |
|
|
304 | (2) |
|
|
|
306 | (1) |
|
|
|
307 | (1) |
|
|
|
308 | (1) |
|
|
|
309 | (26) |
|
|
|
310 | (1) |
|
|
|
310 | (1) |
|
Encrypting View Definitions |
|
|
311 | (1) |
|
Creating a View: SQL Server Management Studio |
|
|
312 | (6) |
|
Creating a View Using a View |
|
|
318 | (6) |
|
|
|
324 | (2) |
|
Creating a View: A Query Editor pane |
|
|
326 | (1) |
|
Creating a View: Schemabinding |
|
|
327 | (3) |
|
|
|
330 | (2) |
|
|
|
332 | (3) |
|
|
|
335 | (24) |
|
What Is a Stored Procedure? |
|
|
335 | (1) |
|
|
|
336 | (3) |
|
Returning a Set of Records |
|
|
339 | (1) |
|
Creating a Stored Procedure: Management Studio |
|
|
339 | (5) |
|
Different Methods of Executing |
|
|
344 | (1) |
|
|
|
344 | (1) |
|
|
|
344 | (1) |
|
|
|
344 | (4) |
|
|
|
348 | (7) |
|
|
|
349 | (1) |
|
|
|
349 | (1) |
|
|
|
350 | (2) |
|
|
|
352 | (3) |
|
|
|
355 | (2) |
|
|
|
357 | (2) |
|
|
|
359 | (44) |
|
Using More Than One Table |
|
|
359 | (6) |
|
|
|
365 | (2) |
|
|
|
367 | (2) |
|
|
|
369 | (3) |
|
|
|
369 | (1) |
|
|
|
370 | (1) |
|
|
|
371 | (1) |
|
|
|
372 | (1) |
|
|
|
372 | (2) |
|
|
|
374 | (1) |
|
|
|
375 | (1) |
|
|
|
376 | (15) |
|
|
|
376 | (4) |
|
|
|
380 | (6) |
|
|
|
386 | (5) |
|
|
|
391 | (3) |
|
|
|
394 | (1) |
|
|
|
395 | (1) |
|
|
|
396 | (5) |
|
|
|
401 | (2) |
|
|
|
403 | (24) |
|
|
|
403 | (4) |
|
|
|
405 | (1) |
|
|
|
406 | (1) |
|
|
|
407 | (2) |
|
|
|
407 | (1) |
|
|
|
408 | (1) |
|
|
|
409 | (3) |
|
|
|
410 | (2) |
|
|
|
412 | (3) |
|
|
|
413 | (1) |
|
|
|
414 | (1) |
|
|
|
415 | (6) |
|
|
|
416 | (2) |
|
|
|
418 | (1) |
|
|
|
419 | (1) |
|
|
|
420 | (1) |
|
|
|
421 | (5) |
|
|
|
424 | (2) |
|
|
|
426 | (1) |
|
|
|
427 | (24) |
|
|
|
427 | (1) |
|
|
|
428 | (1) |
|
Create Trigger Syntax for DML triggers |
|
|
429 | (2) |
|
Why Not Use a Constraint? |
|
|
431 | (1) |
|
Deleted and Inserted Logical Tables |
|
|
431 | (1) |
|
Creating a DML FOR Trigger |
|
|
432 | (4) |
|
Checking Specific Columns |
|
|
436 | (8) |
|
|
|
436 | (5) |
|
|
|
441 | (3) |
|
|
|
444 | (3) |
|
DDL_DATABASE_LEVEL_EVENTS |
|
|
445 | (2) |
|
|
|
447 | (1) |
|
|
|
447 | (3) |
|
|
|
450 | (1) |
|
SQL Server 2005 Reporting Services |
|
|
451 | (22) |
|
What Is Reporting Services? |
|
|
451 | (1) |
|
Reporting Services Architecture from 5000 Feet |
|
|
452 | (1) |
|
Reporting Services Architecture: A Closer Look |
|
|
453 | (5) |
|
|
|
454 | (2) |
|
|
|
456 | (2) |
|
|
|
458 | (1) |
|
Building Your First Report Using Report Wizard |
|
|
458 | (4) |
|
Building a Report from Scratch |
|
|
462 | (10) |
|
|
|
463 | (1) |
|
|
|
463 | (1) |
|
|
|
464 | (8) |
|
|
|
472 | (1) |
| Appendix Glossary of Terms |
|
473 | (12) |
| Index |
|
485 | |