Beginning Microsoft SQL Server 2008 ... - S3 Tech Training
Beginning Microsoft SQL Server 2008 ... - S3 Tech Training Beginning Microsoft SQL Server 2008 ... - S3 Tech Training
Contents xxiv Control-of-Flow Statements 349 The IF … ELSE Statement 350 The ELSE Clause 351 Grouping Code into Blocks 352 The CASE Statement 354 A Simple CASE 354 A Searched CASE 356 Looping with the WHILE Statement 359 The WAITFOR Statement 360 The DELAY Parameter 361 The TIME Parameter 361 TRY/CATCH Blocks 361 Summary 364 Exercises 365 Chapter 12: Stored Procedures 367 Creating the Sproc: Basic Syntax 368 An Example of a Basic Sproc 368 Changing Stored Procedures with AL TER 369 Dropping Sprocs 370 Parameterization 370 Declaring Parameters 370 Supplying Default Values 372 Creating Output Parameters 373 Confirming Success or F ailure with Retur n Values 376 How to Use RETURN 376 More On Dealing with Er rors 378 The Way We Were … 379 Handling Inline Errors 379 Making Use of @@ERROR 380 Using @@ERROR in a Sproc 381 Handling Errors Before They Happen 384 Manually Raising Errors 390 Message ID/Message String 390 Severity 390 State 391 Error Arguments 391 WITH 393 Adding Your Own Custom Error Messages 393 @lang 394
Contents @with_log 394 @replace 394 Using sp_addmessage 394 Removing an Existing Custom Message 395 What a Sproc Offer s 395 Creating Callable Processes 395 Using Sprocs for Security 396 Sprocs and Performance 396 When a Good Sproc Goes Bad 398 Extended Stored Procedures (XPs) 399 A Brief Look at Recur sion 399 Debugging 402 Starting the Debugger 402 Parts of the Debugger 402 The Locals Window 403 The Watch Window 404 The Call Stack Window 405 The Output Window 405 The Command Window 405 Using the Debugger Once It’s Started 406 .NET Assemblies 407 Summary 409 Chapter 13: User-Defined Functions 411 What a UDF Is 411 UDFs Retur ning a Scalar V alue 412 UDFs That Retur n a Table 416 Understanding Determinism 423 Debugging User-Defined Functions 425 .NET in a Database W orld 425 Summary 426 Exercise 426 Chapter 14: T ransactions and Locks 427 Transactions 427 BEGIN TRAN 428 COMMIT TRAN 429 ROLLBACK TRAN 429 SAVE TRAN 429 xxv
- Page 2 and 3: Programmer to Programmer Get more
- Page 5: Beginning Microsoft SQL Ser ver® 2
- Page 8 and 9: Beginning Microsoft SQL Ser ver® 2
- Page 11: About the Author Experiencing his f
- Page 15: Acknowledgments Over the years, the
- Page 18 and 19: Contents Chapter 2:T ools of the T
- Page 20 and 21: Contents xviii The CREATE Statement
- Page 22 and 23: Contents xx Correlated Subqueries 1
- Page 24 and 25: Contents xxii SORT_IN_TEMPDB 280 ON
- Page 28 and 29: Contents xxvi How the SQL Ser ver L
- Page 30 and 31: Contents Chapter 16: A Brief XML Pr
- Page 32 and 33: Contents Chapter 19: Pla ying Admin
- Page 34 and 35: Introduction The beginning user wil
- Page 36 and 37: Introduction ❏ We show file names
- Page 38 and 39: Introduction xxxvi ❏ Understand t
- Page 40 and 41: Chapter 1: RDBMS Basics: What Makes
- Page 42 and 43: Chapter 1: RDBMS Basics: What Makes
- Page 44 and 45: Chapter 1: RDBMS Basics: What Makes
- Page 46 and 47: Chapter 1: RDBMS Basics: What Makes
- Page 48 and 49: Chapter 1: RDBMS Basics: What Makes
- Page 50 and 51: Chapter 1: RDBMS Basics: What Makes
- Page 52 and 53: Chapter 1: RDBMS Basics: What Makes
- Page 54 and 55: Chapter 1: RDBMS Basics: What Makes
- Page 56 and 57: Chapter 1: RDBMS Basics: What Makes
- Page 58 and 59: Chapter 1: RDBMS Basics: What Makes
- Page 60 and 61: Chapter 2: Tools of the Trade 22 My
- Page 62 and 63: Chapter 2: Tools of the Trade ❑ S
- Page 64 and 65: Chapter 2: Tools of the Trade 26 Ke
- Page 66 and 67: Chapter 2: Tools of the Trade 28 Th
- Page 68 and 69: Chapter 2: Tools of the Trade 30 lo
- Page 70 and 71: Chapter 2: Tools of the Trade 32 3.
- Page 72 and 73: Chapter 2: Tools of the Trade 34 Fi
- Page 74 and 75: Chapter 2: Tools of the Trade Figur
Contents<br />
@with_log 394<br />
@replace 394<br />
Using sp_addmessage 394<br />
Removing an Existing Custom Message 395<br />
What a Sproc Offer s 395<br />
Creating Callable Processes 395<br />
Using Sprocs for Security 396<br />
Sprocs and Performance 396<br />
When a Good Sproc Goes Bad 398<br />
Extended Stored Procedures (XPs) 399<br />
A Brief Look at Recur sion 399<br />
Debugging 402<br />
Starting the Debugger 402<br />
Parts of the Debugger 402<br />
The Locals Window 403<br />
The Watch Window 404<br />
The Call Stack Window 405<br />
The Output Window 405<br />
The Command Window 405<br />
Using the Debugger Once It’s Started 406<br />
.NET Assemblies 407<br />
Summary 409<br />
Chapter 13: User-Defined Functions 411<br />
What a UDF Is 411<br />
UDFs Retur ning a Scalar V alue 412<br />
UDFs That Retur n a Table 416<br />
Understanding Determinism 423<br />
Debugging User-Defined Functions 425<br />
.NET in a Database W orld 425<br />
Summary 426<br />
Exercise 426<br />
Chapter 14: T ransactions and Locks 427<br />
Transactions 427<br />
BEGIN TRAN 428<br />
COMMIT TRAN 429<br />
ROLLBACK TRAN 429<br />
SAVE TRAN 429<br />
xxv