17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

very few of your tables will have small record counts. You don’t want to have to go scrolling through 10,000<br />

records. What if you had 100,000 or 1,000,000? Even if you felt like scrolling through them all, the time<br />

before the results were back would be increased dramatically. Finally, what do you do when you’re<br />

designing this into your application and you need a quick result that gets straight to the point?<br />

Figure 3-2<br />

What we’re after is a conditional statement that will limit the results of our query to just one product<br />

identifier — 356. That’s where the WHERE clause comes in. The WHERE clause immediately follows the<br />

FROM clause and defines what conditions a record has to meet before it will be shown. For our query, we<br />

would want the ProductID to be equal to 356, so let’s finish our query:<br />

SELECT Name, ProductNumber, ReorderPoint<br />

FROM Production.Product<br />

WHERE ProductID = 356<br />

Run this query against the AdventureWorks<strong>2008</strong> database and you should come up with:<br />

Name ProductNumber ReorderPoint<br />

----------------------------- ------------------ ------------<br />

LL Grip Tape GT-0820 600<br />

(1 row(s) affected)<br />

Chapter 3: The Foundation Statements of T-<strong>SQL</strong><br />

49

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!