Monday, April 12, 2010

Using SQL Query Analyzer


1. From the Microsoft SQL Server program group, choose Query Analyzer to
run SQL Query Analyzer.

2. Look at the Connect To SQL Server dialog box. You use this dialog box
to specify which SQL server you want to connect to as well as how you
want to log in to the server. In the SQL Server text box, type . to specify
your local server. Below Connect Using, select Windows Authentication.


3. Click OK to log in to your server with Windows Authentication.
Lesson 1: An Overview of SQL Server 13
distribution History information about replication. SQL Server creates this database on
your server only if you configure replication.
DO NOT DUPLICATE
Instructor Edition


4. Look at the SQL Query Analyzer interface. By default, SQL Query Analyzer
displays the Editor pane in the Query window and the Object Browser
window. (You don’t see the Results pane because you haven’t yet executed a
query.) SQL Query Analyzer also connects you to your login account’s
default database. Your login account was assigned the master database as its
default database during classroom setup.


5. In the Object Browser window, expand the pubs database. You now see a
list of folders containing the different types of objects within the pubs
database.
14

6. Expand the User Tables folder and the dbo.authors table within it. You
can use the Object Browser window to display a list of the columns,
indexes, constraints, and triggers for this table. You can also use the Object
Browser window to identify other objects that are based on this table (such
as views, stored procedures, and indexes). We’re going to talk more about
the types of objects you can create within a database in the next topic.
7. Expand the Columns folder to display a list of the columns that make up


the authors table. You can use this information to help you write a query to
query the authors table.

8. From the Database drop-down list, select pubs. You’re going to query the
pubs database.

9. In the Editor pane, type the following query:


10. Choose Query→Execute to have SQL Server process



11. Look at the Results pane. SQL Query Analyzer displays the results of your
query in a separate pane in the window.
12. Choose Edit→Clear Window (or press [Ctrl][Shift][Delete]) to clear your
previous query from the Editor pane. Notice that clearing the Editor pane
doesn’t clear the Results pane.