Introduction |
|
xxi | |
|
Part 1 Introducing SQL Server Express |
|
|
1 | (62) |
|
Introduction to SQL Server Express |
|
|
3 | (8) |
|
|
3 | (1) |
|
Administering SQL Server Express |
|
|
4 | (5) |
|
Opening Management Studio |
|
|
4 | (2) |
|
|
6 | (1) |
|
Using the Configuration Manager |
|
|
7 | (2) |
|
|
9 | (1) |
|
|
9 | (1) |
|
|
10 | (1) |
|
Overview of Database Concepts |
|
|
11 | (18) |
|
|
11 | (3) |
|
File-Server and Client-Server Databases |
|
|
12 | (1) |
|
|
13 | (1) |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
14 | (6) |
|
Records, Fields, and Values |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
15 | (1) |
|
|
16 | (1) |
|
|
16 | (3) |
|
|
19 | (1) |
|
|
19 | (1) |
|
|
20 | (3) |
|
|
23 | (1) |
|
|
24 | (1) |
|
|
24 | (2) |
|
|
25 | (1) |
|
|
25 | (1) |
|
|
26 | (1) |
|
|
26 | (1) |
|
|
27 | (1) |
|
|
28 | (1) |
|
Overview of SQL Server Express |
|
|
29 | (14) |
|
Programs Installed with SQL Server Express |
|
|
29 | (9) |
|
|
29 | (1) |
|
SQL Server Configuration Manager |
|
|
30 | (4) |
|
|
34 | (4) |
|
Application Programming Interfaces |
|
|
38 | (1) |
|
XML and SQL Server Express |
|
|
39 | (1) |
|
SQL Server Express Storage Concepts |
|
|
39 | (2) |
|
|
40 | (1) |
|
|
41 | (1) |
|
|
41 | (2) |
|
Database Design and Normalization |
|
|
43 | (20) |
|
|
43 | (6) |
|
|
43 | (3) |
|
|
46 | (1) |
|
|
47 | (2) |
|
|
49 | (1) |
|
|
49 | (3) |
|
Defining First Normal Form |
|
|
50 | (1) |
|
Identifying a Primary Key |
|
|
51 | (1) |
|
|
52 | (2) |
|
Foreign Keys and Relations |
|
|
53 | (1) |
|
|
54 | (1) |
|
|
55 | (2) |
|
|
57 | (1) |
|
|
57 | (1) |
|
|
58 | (1) |
|
|
58 | (2) |
|
|
59 | (1) |
|
Declarative Referential Integrity |
|
|
60 | (1) |
|
Cascading Referential Integrity |
|
|
61 | (1) |
|
|
61 | (2) |
|
|
63 | (120) |
|
Transact-SQL Overview and Basics |
|
|
65 | (36) |
|
|
65 | (8) |
|
|
65 | (1) |
|
|
66 | (1) |
|
SQL Configuration Options |
|
|
66 | (7) |
|
T-SQL Syntax and Conventions |
|
|
73 | (3) |
|
|
73 | (1) |
|
|
74 | (1) |
|
|
75 | (1) |
|
|
76 | (1) |
|
|
76 | (5) |
|
|
76 | (1) |
|
|
77 | (1) |
|
|
78 | (1) |
|
|
78 | (1) |
|
|
78 | (1) |
|
|
78 | (1) |
|
|
79 | (1) |
|
Special-Purpose Native Datatypes |
|
|
79 | (1) |
|
|
80 | (1) |
|
|
81 | (2) |
|
|
81 | (1) |
|
Operator Precedence and Grouping |
|
|
82 | (1) |
|
|
83 | (1) |
|
|
83 | (3) |
|
|
83 | (3) |
|
|
86 | (1) |
|
|
86 | (8) |
|
|
88 | (1) |
|
|
89 | (1) |
|
|
90 | (1) |
|
|
91 | (1) |
|
System and Metadata Functions |
|
|
92 | (1) |
|
|
92 | (2) |
|
Using Command-Line Utilities |
|
|
94 | (5) |
|
|
95 | (2) |
|
|
97 | (2) |
|
|
99 | (2) |
|
|
101 | (30) |
|
|
101 | (6) |
|
|
102 | (1) |
|
Limiting Records with the Where Clause |
|
|
103 | (3) |
|
|
106 | (1) |
|
|
107 | (5) |
|
|
107 | (2) |
|
|
109 | (2) |
|
|
111 | (1) |
|
Bringing Order to the Results |
|
|
112 | (15) |
|
|
112 | (1) |
|
Using Group By and Having |
|
|
113 | (5) |
|
|
118 | (2) |
|
|
120 | (2) |
|
|
122 | (4) |
|
|
126 | (1) |
|
|
127 | (2) |
|
|
129 | (2) |
|
|
131 | (20) |
|
|
131 | (1) |
|
|
132 | (3) |
|
|
132 | (1) |
|
|
132 | (2) |
|
|
134 | (1) |
|
|
134 | (1) |
|
Limitations of Truncate Table |
|
|
135 | (1) |
|
Example of Truncate Table |
|
|
135 | (1) |
|
|
135 | (7) |
|
|
136 | (1) |
|
|
137 | (1) |
|
|
137 | (5) |
|
|
142 | (7) |
|
|
142 | (2) |
|
|
144 | (1) |
|
|
145 | (1) |
|
|
146 | (1) |
|
Limitations of Select Into |
|
|
147 | (1) |
|
|
148 | (1) |
|
|
149 | (2) |
|
Topics in Advanced Transact-SQL |
|
|
151 | (32) |
|
|
151 | (6) |
|
|
152 | (1) |
|
|
153 | (4) |
|
|
157 | (1) |
|
|
157 | (9) |
|
|
158 | (1) |
|
|
158 | (1) |
|
|
159 | (1) |
|
|
159 | (7) |
|
|
166 | (8) |
|
|
166 | (2) |
|
|
168 | (1) |
|
|
169 | (2) |
|
|
171 | (1) |
|
|
172 | (1) |
|
|
172 | (2) |
|
Using the System Tables and Information Schema Views |
|
|
174 | (5) |
|
What's in the System Tables? |
|
|
175 | (2) |
|
Sample System Table Queries |
|
|
177 | (1) |
|
|
178 | (1) |
|
|
179 | (3) |
|
|
180 | (1) |
|
|
181 | (1) |
|
|
181 | (1) |
|
|
182 | (1) |
|
|
182 | (1) |
|
Part 3 Digging into SQL Server Express |
|
|
183 | (156) |
|
Using Management Studio Express |
|
|
185 | (30) |
|
Introduction to Microsoft SQL Server Management Studio Express |
|
|
185 | (2) |
|
|
187 | (24) |
|
The Object Explorer Window |
|
|
187 | (24) |
|
|
211 | (1) |
|
|
212 | (1) |
|
|
213 | (2) |
|
|
215 | (20) |
|
|
215 | (2) |
|
|
217 | (1) |
|
|
218 | (6) |
|
Creating Databases with Management Studio |
|
|
218 | (3) |
|
Creating Databases with T-SQL |
|
|
221 | (3) |
|
|
224 | (9) |
|
|
225 | (4) |
|
|
229 | (4) |
|
|
233 | (2) |
|
|
235 | (28) |
|
|
235 | (5) |
|
|
240 | (1) |
|
|
240 | (5) |
|
|
245 | (16) |
|
Enforcing Domain Integrity |
|
|
245 | (4) |
|
Enforcing Entity Integrity |
|
|
249 | (4) |
|
Enforcing Referential Integrity |
|
|
253 | (8) |
|
|
261 | (2) |
|
|
263 | (10) |
|
|
263 | (7) |
|
|
263 | (2) |
|
Understanding Clustered Indexes |
|
|
265 | (2) |
|
Understanding Nonclustered Indexes |
|
|
267 | (3) |
|
|
270 | (2) |
|
|
272 | (1) |
|
|
273 | (26) |
|
Using Views to Partition Tables |
|
|
273 | (5) |
|
|
274 | (4) |
|
|
278 | (1) |
|
|
279 | (2) |
|
Organizing the Result Set |
|
|
281 | (2) |
|
Using Views to Join Tables |
|
|
283 | (4) |
|
Joining Multiple Tables in a View |
|
|
285 | (2) |
|
Modifying Data through a View |
|
|
287 | (4) |
|
Enhancing Views with Inline User-Defined Functions |
|
|
291 | (1) |
|
Using Information Schema Views |
|
|
292 | (3) |
|
|
295 | (2) |
|
|
297 | (2) |
|
|
299 | (16) |
|
Understanding Stored Procedures |
|
|
299 | (10) |
|
|
300 | (2) |
|
|
302 | (2) |
|
|
304 | (2) |
|
Optimizing Stored Procedures |
|
|
306 | (1) |
|
Securing Your Stored Procedures |
|
|
307 | (2) |
|
Using System and Extended Stored Procedures |
|
|
309 | (4) |
|
Using System Stored Procedures |
|
|
309 | (3) |
|
Using Extended Stored Procedures |
|
|
312 | (1) |
|
|
313 | (2) |
|
|
315 | (24) |
|
|
315 | (16) |
|
Working with Insert Triggers |
|
|
316 | (4) |
|
Working with Delete Triggers |
|
|
320 | (2) |
|
Working with Update Triggers |
|
|
322 | (7) |
|
Working with Instead of Triggers |
|
|
329 | (2) |
|
|
331 | (7) |
|
|
331 | (1) |
|
Reporting Errors with Raiserror() |
|
|
332 | (2) |
|
|
334 | (2) |
|
|
336 | (2) |
|
|
338 | (1) |
|
Part 4 Administering SQL Server Express |
|
|
339 | (56) |
|
Basic Administrative Tasks |
|
|
341 | (34) |
|
|
341 | (18) |
|
|
342 | (1) |
|
SQL Server Express Creating a Backup Device |
|
|
343 | (1) |
|
|
344 | (2) |
|
Performing Differential Backups |
|
|
346 | (2) |
|
Performing Transaction Log Backups |
|
|
348 | (3) |
|
Performing Filegroup Backups |
|
|
351 | (5) |
|
Backing Up to Multiple Devices |
|
|
356 | (3) |
|
|
359 | (7) |
|
|
359 | (3) |
|
|
362 | (3) |
|
|
365 | (1) |
|
Devising a Backup Strategy |
|
|
366 | (3) |
|
|
366 | (1) |
|
Full with Differential Backups |
|
|
367 | (1) |
|
Full with Transaction Log Backups |
|
|
368 | (1) |
|
Full, Differential, and Transaction Log Backups |
|
|
368 | (1) |
|
|
369 | (1) |
|
|
369 | (4) |
|
Understanding DM_DB_Index_Physical_Stats |
|
|
370 | (2) |
|
|
372 | (1) |
|
|
373 | (2) |
|
Security and SQL Server Express |
|
|
375 | (20) |
|
|
375 | (1) |
|
Understanding Security Modes |
|
|
376 | (2) |
|
Windows NT/2000 Authentication Mode |
|
|
376 | (1) |
|
|
376 | (1) |
|
Setting the Authentication Mode |
|
|
377 | (1) |
|
SQL Server Express Logins |
|
|
378 | (3) |
|
|
378 | (3) |
|
|
381 | (2) |
|
Creating Database User Accounts |
|
|
383 | (1) |
|
Understanding Permissions |
|
|
384 | (3) |
|
|
385 | (1) |
|
|
386 | (1) |
|
|
387 | (4) |
|
|
388 | (1) |
|
|
388 | (2) |
|
|
390 | (1) |
|
|
391 | (1) |
|
|
392 | (1) |
|
|
393 | (2) |
|
Part 5 Developing Applications with SQL Server Express |
|
|
395 | (74) |
|
Working with Visual Basic Express |
|
|
397 | (20) |
|
Feeling at Home with VB Express |
|
|
397 | (1) |
|
Creating a VB Express Application |
|
|
398 | (13) |
|
|
398 | (4) |
|
Connecting to a SQL Server Express Database |
|
|
402 | (5) |
|
Designing a Data Access Form |
|
|
407 | (4) |
|
|
411 | (4) |
|
Publishing a Project to CD-ROM |
|
|
411 | (4) |
|
|
415 | (2) |
|
Accessing Data Using ADO.NET |
|
|
417 | (28) |
|
ADO.NET Namespaces and Classes |
|
|
417 | (2) |
|
|
418 | (1) |
|
Understanding the SQLClientData Provider |
|
|
419 | (1) |
|
|
419 | (1) |
|
Making and Managing Connections |
|
|
419 | (3) |
|
Building Connection Strings |
|
|
420 | (2) |
|
Handling Connection Pooling |
|
|
422 | (1) |
|
Using the SqlCommand Object |
|
|
422 | (4) |
|
|
422 | (2) |
|
|
424 | (1) |
|
Retrieving a Single Value |
|
|
425 | (1) |
|
Using the SqlDataReader Object |
|
|
426 | (4) |
|
|
426 | (1) |
|
|
427 | (3) |
|
Using the DataSet and SqlDataAdapter Objects |
|
|
430 | (14) |
|
Setting Up the SqlDataAdapter |
|
|
430 | (2) |
|
|
432 | (3) |
|
|
435 | (6) |
|
|
441 | (1) |
|
|
442 | (2) |
|
|
444 | (1) |
|
Automating SQL Server Express Using SMO and RMO |
|
|
445 | (24) |
|
|
445 | (1) |
|
|
446 | (13) |
|
|
446 | (2) |
|
|
448 | (4) |
|
|
452 | (1) |
|
|
453 | (1) |
|
The DatabaseOptions Object |
|
|
454 | (1) |
|
The StoredProcedure Object |
|
|
455 | (2) |
|
|
457 | (1) |
|
|
458 | (1) |
|
|
459 | (6) |
|
Creating and Connecting a Server Object |
|
|
460 | (1) |
|
|
461 | (1) |
|
Changing a Configuration Option |
|
|
461 | (1) |
|
|
462 | (1) |
|
|
463 | (1) |
|
Creating and Executing a Stored Procedure |
|
|
463 | (2) |
|
|
465 | (2) |
|
|
467 | (2) |
|
Part 6 Advanced SQL Server Express Administration |
|
|
469 | (70) |
|
|
471 | (18) |
|
|
471 | (2) |
|
|
471 | (1) |
|
|
472 | (1) |
|
|
472 | (1) |
|
|
472 | (1) |
|
Optimistic and Pessimistic Concurrency |
|
|
472 | (1) |
|
|
473 | (1) |
|
|
474 | (3) |
|
|
474 | (1) |
|
|
475 | (1) |
|
|
476 | (1) |
|
|
477 | (1) |
|
|
477 | (5) |
|
|
477 | (2) |
|
|
479 | (3) |
|
|
482 | (2) |
|
Customizing Locking Behavior |
|
|
484 | (2) |
|
|
484 | (1) |
|
Setting the Transaction Isolation Level |
|
|
484 | (2) |
|
|
486 | (1) |
|
|
486 | (2) |
|
|
487 | (1) |
|
|
488 | (1) |
|
|
488 | (1) |
|
Monitoring and Optimizing SQL Server Express |
|
|
489 | (12) |
|
Using Performance Monitor |
|
|
489 | (5) |
|
Using Management Studio's Query Editor |
|
|
494 | (2) |
|
|
496 | (1) |
|
Setting a Measurement Baseline |
|
|
496 | (1) |
|
Data Archiving and Trend Tracking |
|
|
497 | (1) |
|
|
497 | (1) |
|
Queries and Stored Procedures |
|
|
497 | (1) |
|
|
498 | (1) |
|
|
498 | (1) |
|
|
498 | (1) |
|
|
499 | (2) |
|
|
501 | (10) |
|
Understanding Replication |
|
|
501 | (8) |
|
The Publisher/Subscriber Metaphor |
|
|
502 | (1) |
|
|
503 | (3) |
|
|
506 | (1) |
|
|
507 | (2) |
|
|
509 | (2) |
|
|
511 | (18) |
|
Understanding Service Broker |
|
|
511 | (1) |
|
|
512 | (2) |
|
|
514 | (4) |
|
|
514 | (1) |
|
Asynchronous Queued Transactional Messaging |
|
|
515 | (1) |
|
|
516 | (2) |
|
Service Broker Programming |
|
|
518 | (5) |
|
Creating a Service Broker Application |
|
|
518 | (3) |
|
Creating a Queue-Reading Stored Procedure |
|
|
521 | (2) |
|
Administering Service Broker |
|
|
523 | (4) |
|
Managing Applications and Queues |
|
|
523 | (2) |
|
|
525 | (1) |
|
System Configuration Options |
|
|
525 | (1) |
|
Service Broker Catalog Views |
|
|
526 | (1) |
|
|
527 | (2) |
|
|
529 | (10) |
|
|
529 | (2) |
|
|
531 | (1) |
|
Troubleshooting Databases |
|
|
532 | (3) |
|
|
532 | (2) |
|
Repairing Shutdown Databases |
|
|
534 | (1) |
|
Troubleshooting Backup and Restores |
|
|
535 | (1) |
|
Troubleshooting Client Connectivity |
|
|
536 | (1) |
|
|
537 | (2) |
|
Appendix A Transact-SQL Reference |
|
|
539 | (8) |
|
|
539 | (1) |
|
|
540 | (1) |
|
|
541 | (1) |
|
|
542 | (1) |
|
|
542 | (1) |
|
|
543 | (1) |
|
|
543 | (1) |
|
|
544 | (1) |
|
|
544 | (1) |
|
|
545 | (2) |
Index |
|
547 | |