Database Reference
In-Depth Information
In many database applications, a query window may hold only a single statement or batch of statements at
a time, but this is not true in SQL Server Management Studio. Instead, you can type in hundreds of lines of SQL
code and execute them independently, as a batch, or as several batches by selecting whichever statements you
want to run.
If no statements are highlighted, all the statements in the query window run sequentially. In Figure 5-10 you
see two SQL statements have been typed into the query window, but only one statement has been selected. In
this example, only the highlighted statement will be executed when “! Execute” is clicked.
The term SQL batch is used to describe one or more SQL statements that are submitted to the database en-
gine as a unit. Some statements, such as the CREATE PROCEDURE statement, must be the first statement in a batch,
but most statements can be submitted in any order. If you want to create multiple procedures in one query window,
you can use the batch separator keyword GO to divide the SQL statements into multiple batches. You may also use
the GO keyword between any of the individual statements, but this is more of a stylistic choice than a programmatic
one and is not necessary for your statements to execute correctly. Examples of this are shown throughout the code
samples of this topic.
Tip
SQL code can be submitted to the database engine from other applications as well as SQL Server
Management Studio. Simple examples of this are executing code from SSIS and SSRS. We investigate both of
these in later chapters of this topic.
Creating Data Warehouse Database
With SQL Server Management Studio, you can easily create a database by right-clicking the database icon in
Object Explorer, as shown in Figure 5-11 . This launches the New Database dialog window. When the dialog
window opens, there is a selection of pages on the left of the dialog window, and on the right are associated
text boxes and grids. To create a database, select the general page and provide a name for the database such as
DWPubSales; then indicate the owner of the database as the system administrator account, SA.
 
 
Search WWH ::




Custom Search