Database Reference
In-Depth Information
Tip I've written SELECT and FROM in capital letters simply to indicate they're SQL keywords. SQL isn't case-
sensitive, and keywords are typically written in lowercase in code. In T-SQL, queries are called SELECT statements,
but the ISO/ANSI standard clearly distinguishes “queries” from “statements.” The distinction is conceptually
important. A query is an operation on a table that produces a table as a result; statements may (or may not)
operate on tables and don't produce tables as results. Furthermore, subqueries can be used in both queries and
statements. So, we'll typically call queries queries instead of SELECT statements. Call queries whatever you prefer,
but keep in mind that queries are a special feature of SQL.
Using two keywords, SELECT and FROM , here's the simplest possible query that will get all the data
from the specified table:
Select * from <table name>
The asterisk (*) means you want to select all the columns in the table.
You will be using an instance of SQL Server 2012 in this chapter. Open SQL Server Management
Studio, and in the Connect to Server dialog box type localhost \<SQL Server 2012 instance name> as the
server name; then click Connect. SQL Server Management Studio will open. Expand the Databases node,
and select the AdventureWorks database. Your screen should resemble Figure 5-1.
Figure 5-1. Selecting a database to query
 
Search WWH ::




Custom Search