Chapter 9. Scripts and Batches

Geez. I've been writing too long. For some reason, when I see the phrase "Scripts and Batches" it reminds me of the old song "Love and Marriage" (Frank Sinatra for the curious). While scripts and batches do go together like a horse and carriage, they are hardly as lyrical — but I digress....

We have, of course, already written many SQL scripts in this book. My assumption, given that this is a "Professional" level book, is that you already have most of the script basics down. After all, every CREATE statement that you write, every ALTER, every SELECT is all (if you're running a single statement) or part (multiple statements) of a script. It is, however, rather difficult to get excited about a script with one line in it. Could you imagine Hamlet's "To be, or not to be ...?" if it had never had the following lines. We wouldn't have any context for what he was talking about.

SQL scripts are much the same way. Things get quite a bit more interesting when we string several commands together into a longer script — a full play or at least an act to finish our Shakespeare analogy. Now imagine that we add a richer set of language elements from .NET to the equation. Now we're ready to write an epic!

Scripts generally have a unified goal. That is, all the commands that are in a script are usually building up to one overall purpose. Examples include scripts to build a database (these might be used for a system installation), scripts for system maintenance, such as ...

Get Professional Microsoft® SQL Server® 2008 Programming 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.