Introduction |
|
1 | (1) |
|
|
1 | (1) |
|
|
2 | (3) |
|
Stored Procedures Overview |
|
|
5 | (30) |
|
What is a Stored Procedure? |
|
|
6 | (5) |
|
|
6 | (2) |
|
|
8 | (1) |
|
Creating Stored Procedures |
|
|
9 | (2) |
|
Performance Consideration |
|
|
11 | (1) |
|
|
11 | (1) |
|
Why Use Stored Procedures? |
|
|
11 | (1) |
|
|
12 | (1) |
|
Designing Good Stored Procedures |
|
|
13 | (1) |
|
|
14 | (3) |
|
Calling a Stored Procedure |
|
|
17 | (1) |
|
Rules for Stored Procedures |
|
|
17 | (2) |
|
Modifying Stored Procedures |
|
|
19 | (1) |
|
|
20 | (1) |
|
|
21 | (6) |
|
|
21 | (1) |
|
|
22 | (1) |
|
|
22 | (1) |
|
|
23 | (2) |
|
|
25 | (1) |
|
|
25 | (1) |
|
|
25 | (1) |
|
Pausing and Halting execution |
|
|
26 | (1) |
|
Nesting in Stored Procedures |
|
|
27 | (1) |
|
|
28 | (3) |
|
|
28 | (1) |
|
|
29 | (1) |
|
|
30 | (1) |
|
|
30 | (1) |
|
Other Issues with Returning Values |
|
|
30 | (1) |
|
Restoring the Example Databases to their Default Condition |
|
|
31 | (1) |
|
|
31 | (4) |
|
|
35 | (30) |
|
Optimizing Stored Procedures |
|
|
35 | (3) |
|
|
35 | (2) |
|
|
37 | (1) |
|
|
38 | (10) |
|
Why Bother About the Execution Plan? |
|
|
39 | (1) |
|
Viewing the Execution Plan |
|
|
39 | (1) |
|
Graphical View of the Execution Plan |
|
|
39 | (1) |
|
Textual View of the Execution Plan |
|
|
40 | (2) |
|
The Execution Plan and Stored Procedures |
|
|
42 | (1) |
|
Multiple Statements within the Stored Procedure |
|
|
43 | (1) |
|
Understanding the Execution Plan |
|
|
44 | (1) |
|
|
44 | (3) |
|
Benefits of Understanding Cost |
|
|
47 | (1) |
|
|
48 | (4) |
|
|
48 | (2) |
|
Dynamic SQL in Procedures |
|
|
50 | (1) |
|
|
51 | (1) |
|
|
52 | (5) |
|
|
53 | (2) |
|
Raiserror & Return Parameters |
|
|
55 | (2) |
|
|
57 | (5) |
|
|
57 | (1) |
|
|
58 | (4) |
|
|
62 | (3) |
|
Concurrency, Cursors, and Transactions |
|
|
65 | (46) |
|
|
66 | (15) |
|
|
66 | (1) |
|
|
67 | (3) |
|
|
70 | (1) |
|
Accessing Cursors from Code |
|
|
70 | (1) |
|
|
70 | (1) |
|
|
70 | (2) |
|
|
72 | (1) |
|
|
73 | (1) |
|
|
73 | (1) |
|
|
73 | (5) |
|
|
78 | (2) |
|
|
80 | (1) |
|
|
81 | (10) |
|
|
82 | (1) |
|
|
82 | (4) |
|
|
86 | (1) |
|
|
87 | (1) |
|
Explicit versus Implicit Transactions |
|
|
88 | (1) |
|
|
88 | (2) |
|
|
90 | (1) |
|
|
91 | (18) |
|
|
92 | (1) |
|
|
92 | (1) |
|
|
93 | (6) |
|
Coding for Integrity and Concurrency |
|
|
99 | (9) |
|
|
108 | (1) |
|
|
109 | (2) |
|
Common Practices with Stored Procedures |
|
|
111 | (24) |
|
|
111 | (18) |
|
|
112 | (3) |
|
|
115 | (5) |
|
|
120 | (1) |
|
|
120 | (1) |
|
Simplifying Code Deployment |
|
|
120 | (1) |
|
Improving Database Security |
|
|
121 | (1) |
|
Improving Data Validation |
|
|
122 | (2) |
|
|
124 | (1) |
|
Why not Build Validation in the Front-End Application? |
|
|
125 | (1) |
|
|
126 | (1) |
|
Executing Code at SQL Server Startup |
|
|
127 | (2) |
|
Points to Avoid While Using Stored Procedures |
|
|
129 | (4) |
|
Stored Procedure Grouping |
|
|
129 | (2) |
|
Nesting Stored Procedures |
|
|
131 | (1) |
|
Generic Stored Procedures |
|
|
131 | (1) |
|
Stored Procedures with Many Parameters |
|
|
131 | (2) |
|
|
133 | (2) |
|
|
135 | (44) |
|
|
136 | (15) |
|
Effect of the 0x80000000 Status Bit |
|
|
138 | (2) |
|
Making System Stored Procedures with the 0x80000000 Bit |
|
|
140 | (2) |
|
An Important Feature of System Stored Procedures |
|
|
142 | (2) |
|
Other Features of SP_: Global Tables and Views |
|
|
144 | (1) |
|
Common Documented System Stored Procedures |
|
|
145 | (4) |
|
Other Important System Stored Procedures |
|
|
149 | (1) |
|
Mining System Stored Procedures |
|
|
150 | (1) |
|
Undocumented Functionality |
|
|
151 | (15) |
|
Finding Undocumented Extended Stored Procedure Functionality |
|
|
152 | (1) |
|
Windows-Registry Related Stored Procedures |
|
|
152 | (1) |
|
|
152 | (1) |
|
|
153 | (2) |
|
|
155 | (1) |
|
|
156 | (1) |
|
|
157 | (1) |
|
|
157 | (1) |
|
|
158 | (1) |
|
|
158 | (1) |
|
|
159 | (1) |
|
XP_Instance_Reg extended stored procedures |
|
|
160 | (1) |
|
|
161 | (1) |
|
|
161 | (1) |
|
|
162 | (1) |
|
|
162 | (1) |
|
|
163 | (1) |
|
|
163 | (1) |
|
|
164 | (2) |
|
Performing Complex Tasks with System Stored Procedures |
|
|
166 | (2) |
|
Tracing Object Creation and Deletion |
|
|
168 | (1) |
|
|
169 | (7) |
|
Best Practice Tips for SQL Mail |
|
|
170 | (1) |
|
|
170 | (2) |
|
XP_SendMail Bullet-proofing |
|
|
172 | (1) |
|
Breaking the Exchange Umbilical Cord - XP_SMTP_SendMail |
|
|
172 | (4) |
|
|
176 | (3) |
|
|
179 | (18) |
|
|
179 | (2) |
|
|
180 | (1) |
|
|
181 | (5) |
|
|
181 | (1) |
|
|
182 | (1) |
|
Non-Deterministic Functions |
|
|
182 | (1) |
|
|
182 | (1) |
|
Example of Creating a UDF |
|
|
183 | (1) |
|
Converting a Non-Deterministic Function to Deterministic |
|
|
183 | (3) |
|
|
186 | (2) |
|
|
188 | (5) |
|
Single Statement Table Function |
|
|
188 | (2) |
|
Multi-Statement Table Functions |
|
|
190 | (1) |
|
|
190 | (2) |
|
In-built Functions with Table Data Type |
|
|
192 | (1) |
|
|
193 | (1) |
|
Stored Procedures versus UDFs |
|
|
194 | (1) |
|
|
195 | (2) |
|
|
197 | (22) |
|
|
198 | (2) |
|
|
200 | (1) |
|
|
201 | (1) |
|
Deferred Updates and Direct Updates |
|
|
202 | (1) |
|
Creating and using a trigger |
|
|
202 | (4) |
|
The Conceptual Tables within Triggers |
|
|
204 | (1) |
|
Triggers Fired on an Update |
|
|
205 | (1) |
|
|
206 | (5) |
|
|
206 | (1) |
|
|
206 | (2) |
|
|
208 | (1) |
|
|
209 | (1) |
|
|
210 | (1) |
|
|
210 | (1) |
|
Transactions and Triggers |
|
|
211 | (1) |
|
Trigger versus Constraints |
|
|
212 | (1) |
|
Triggers versus Stored Procedure |
|
|
213 | (1) |
|
|
213 | (2) |
|
|
215 | (1) |
|
|
216 | (1) |
|
|
216 | (1) |
|
|
217 | (2) |
|
|
219 | (28) |
|
Increased Need for Security |
|
|
219 | (1) |
|
SQL Server Vulnerabilities |
|
|
220 | (25) |
|
Misconfiguration of SQL Servers |
|
|
220 | (1) |
|
|
220 | (3) |
|
|
223 | (8) |
|
|
231 | (3) |
|
|
234 | (1) |
|
|
234 | (3) |
|
|
237 | (2) |
|
Encrypting Stored Procedures |
|
|
239 | (1) |
|
|
240 | (1) |
|
Breaking Object Encryption in SQL 2000 |
|
|
241 | (1) |
|
A Strategy For Encrypting Your Data |
|
|
242 | (1) |
|
|
243 | (1) |
|
Installing a SSL Certificate for SQL Server |
|
|
244 | (1) |
|
Importing the certificate: |
|
|
244 | (1) |
|
Using the SetCert utility |
|
|
245 | (1) |
|
|
245 | (2) |
|
Appendix A: Support, Errata, and forums.apress.com |
|
|
247 | (4) |
|
|
247 | (1) |
|
|
247 | (1) |
|
The Peer-to-Peer Forums at forums.apress.com |
|
|
248 | (3) |
Index |
|
251 | |