Welcome to Lesson 2 of the SQL Server 2000 Tutorial. In this lesson we will cover the Query Analyzer. I hope you enjoy the lesson.
Query Analyzer
Query Analyzer
Tutorial
Query Analyzer is used primarily for writing
and debugging T-SQL. Many of the administration aspects of SQL
Server may also be done in Query Analyzer. For example we can
write a script to add users to a database. To open Query
Analyzer go to Start, All Programs, Microsoft SQL Server, Query
Analyzer.
When opening Query Analyzer you will need to select
the SQL Server to connect to as well as choose the type of
authentication to use. For simplicity we will select the
(local) SQL Server and use Windows Authentication.

Depending on how logins are set up, when you connect
with Query Analyzer, you will be put in the default database.
In this instance, our Windows Authentication login put us in the
master database. Use the database dropdown to change the
database you want to work with. Select the Northwind database
form the dropdown.

With Query Analyzer we can write SQL statements to
retrieve data from a database. Write a simple SQL statement SELECT *
FROM employees and click the execute button

Here is the result:

There are many things that makes SQL Analyzer
very powerful. For example when you are finished writing your SQL
statements, you can go to Query, Display Estimated Execution Plan to
see if the SQL statement you wrote was optimized.

We now see execution plan for this simple query.
We also see the cost of each step.

Developers would usually focus on the step that
has the most cost and try to see if there is anything that can be
done to improve the slowest step. Hovering the mouse over the
individual step will display more details about the step

We will revisit other features of Query Analyzer
later in the tutorials.