IX.B.4. I Want to Automate Some Operations

SQL Server offers two very helpful features that you can use to help streamline common database tasks:

  • Stored procedures and functions: Stored procedures and functions are bits of logically grouped application software that you can write in a variety of programming languages, including Transact-SQL, Visual Basic, Visual C#, and so on. After you create them, you then place these procedures inside the SQL Server engine, where anyone with the right permission can run them. This centralizes your application logic, and generally helps performance. If you're curious about stored procedures and functions, check out Book IV, Chapter 2.

  • Triggers: Think of a trigger as a very specialized stored procedure, one that is run when a certain event happens. For example, you might want to send an e-mail alert when inventory drops below a certain level. That's a great use of a trigger; you can probably think of many more that apply in your organization. You can also use triggers to help you administer your database server and run administrative operations. If you want to get a better handle on triggers, have a look at Book IV, Chapter 3.

Get Microsoft® SQL Server™ 2008 All-In-One Desk Reference For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.