III.5.2. Retrieving Data from a Single Table

The simplest query is one that retrieves data from a single table. It doesn't require any join statements; instead, it uses a simple SELECT statement querying only one table.

A SELECT statement is one of several Data Manipulation Language (DML) statements. The SELECT statement reads data only, but doesn't modify it. Other DML statements are:

  • INSERT: Adds new rows to a table.

  • UPDATE: Modifies existing rows in a table.

  • DELETE: Removes rows from a table.

By understanding the SELECT statement in detail, the other DML statements become much easier to grasp.

III.5.2.1. Using IntelliSense

One of the great features of SQL Server 2008 is the introduction of IntelliSense. When you're writing a query, IntelliSense identifies what commands are acceptable and provides you appropriate choices.

For example, you could have your query window pointed at AdventureWorks2008. Your plan is to type in the following query:

SELECT * FROM HumanResources.Employee

However, after you type in the H (as in SELECT * FROM H) an IntelliSense popup window appears, showing you all the possible choices. Because you entered an H, it displays the choices starting with H. Pressing the Tab key, the spacebar, or the Enter key selects the choice you want (in this case, HumanResources).

HumanResources fills in. Type in a period and all the objects in the HumanResources schema appear. Select Employee, press Return, and you're done.

SQL developers have wanted this feature for a ...

Get Microsoft® SQL Server™ 2008 All-In-One Desk Reference For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.