Database Reference
In-Depth Information
4.
At this point you can check the SQL command syntax before actually running the
command by clicking the
Parse
button. A Results window will be displayed in the
same location shown in Figure 2-16, but with the message “Command(s) completed
successfully” if the SQL command syntax is correct or with an error message if there
is a problem with the syntax.
5.
Click the
Execute
button to run the query. The results are displayed in a results win-
dow, as shown in Figure 2-16.
Note that in Figure 2-16 the Cape Codd database object in the Object Browser in the left
side window of the Microsoft SQL Server, Management Studio has been expanded to show
the tables in the Cape Codd database. Many of the functions of the Microsoft SQL Server,
Management Studio are associated with the objects in the Object Browser and are often ac-
cessed by right-clicking the object to display a shortcut menu.
By The Way
We are using Microsoft SQL Server 2012 Enterprise edition running in
Microsoft Server 2012. When we give specific sequences of steps to follow
in the text or figures in this topic, we use the command terminology used by Microsoft
SQL Server 2012 and associated utility programs in Microsoft Server 2012. If you are
running a workstation operating system such as Microsoft XP or Microsoft Vista, the
terminology may vary somewhat.
Microsoft SQL Server 2012 is an enterprise-class DBMS product and, as is typical of such
products, does not store queries within the DBMS (it does store SQL Views, which can be con-
sidered a type of query, and we will discuss SQL Views in Chapter 7). However, you can save
queries as SQL script files. An
SQL script file
is a separately stored plain text file, and it usually
uses a file name extension of
*.sql.
An SQL script can be opened and run as an SQL command
(or set of commands). Often used to create and populate databases, scripts can also be used to
store a query or set of queries. Figure 2-17 shows the SQL query being saved as an SQL script.
Note that in Figure 2-17 the SQL scripts are shown in a folder named
DBP-e13-Cape-Codd-
Database.
When the Microsoft SQL Server 2012 Management Studio is installed, a new folder
named
SQL Server Management Studio
is created in your My Documents folder. Within this
folder, create a
Projects
subfolder, and use the Projects folder as the location for storing your
SQL script files.
Figure 2-17
Saving an SQL Query as an
SQL Script in Microsoft SQL
Server Management Studio
The
Open File
button
The
Save
button
The
Save File As
dialog box
The
DBP-e13-Cape
Codd-Database
folder
Existing SQL scripts—
these were used to
create and populate
the Cape-Codd
database
Type the SQL script
file name here
The
Save
button
Search WWH ::
Custom Search