Chapter 5. Understanding Advanced Database Programming Objects and Error Handling
None of the Transact-SQL code that we have written so far in this book is reusable. SQL Server allows you to create reusable programming objects. The SQL Server reusable programming objects include views, stored procedures, functions, and triggers (based on either DDL or DML). In this chapter, we first take a look at variables. Next, we take a look at control-flow statements. Then we take a look at the design and use of each of the programmable objects in turn. Finally, we learn how to handle errors that occur in the Transact-SQL batches and programmable objects using a TRY...CATCH
construct.
After completing this chapter, you will be able to:
- Create and use variables
- Add logic around and within the Transact-SQL statements to control program execution
- Design and create user-defined views
- Design and create user-defined stored procedures
- Design and create user-defined functions
- Design and create triggers
- Handle...