Database Reference
In-Depth Information
Try It: Running a Simple Query
To submit a query to retrieve all employee data, open a New Query window in SQL Server Management
Studio. Select the AdventureWorks in the Object Explorer, and then click the New Query button on the
toolbar. This will open a New Query window. Enter the following query, and click Execute. You should
see the results shown in Figure 5-2.
Select * from Person.Address
Figure 5-2. Query results pane
How It Works
You ask the database to return the data for all the columns, and you get exactly that. If you scroll to the
right, you'll find all the columns in the Address table.
Most of the time, you should limit queries to only relevant columns. When you select columns you
don't need, you waste resources. To explicitly select columns, enter the column names after the SELECT
keyword, as shown in the following query, and click Execute. Figure 5-3 shows the results.
Select AddressID, AddressLine1, City from Person.Address
This query selects all the rows from the Address table but only the AddressID, AddressLine1, and
City columns.
 
Search WWH ::




Custom Search