Summary
In this chapter you learned the basics of writing stored procedures. We discussed how to monitor stored procedure activity using the Profiler utility, and we dealt with several real-world stored procedure programming issues. You learned about the procedure cache, how SQL Server uses it, and how you can watch it for signs of inefficiencies in your code. You learned about many of the nuances and quirks in SQL Server's stored procedure programming language, Transact-SQL, and you learned how to use them to your advantage and/or how to work around them as appropriate. You learned how to pass parameters to stored procedures, how to return stored procedure status codes, and how to return data via output parameters. We talked about how to nest stored procedures, as well as how to call them recursively. Hopefully, through all this, you've begun to glimpse a bit of the power available to you in Transact-SQL and SQL Server stored procedures. We'll build on this throughout the remainder of the book.