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.

asic SELECT statement. Fire up the <strong>SQL</strong> <strong>Server</strong> Management Studio and let’s take a look at a simple<br />

SELECT statement:<br />

SELECT * FROM INFORMATION_SCHEMA.TABLES;<br />

Let’s look at what we’ve asked for here. We’ve asked to SELECT information; you can also think of this<br />

as requesting to display information. The * may seem odd, but it actually works pretty much as * does<br />

everywhere: It’s a wildcard. When we say SELECT *, we’re saying we want to select every column from<br />

the table. Next, the FROM indicates that we’ve finished saying what items to output and that we’re about<br />

to say what the source of the information is supposed to be — in this case, INFORMATION_SCHEMA.TABLES.<br />

Try It Out The SELECT Statement<br />

Let’s play around with this some more. Change the current database to be the AdventureWorks<strong>2008</strong><br />

database. Recall that to do this, you need only select the AdventureWorks<strong>2008</strong> entry from the combo<br />

box in the toolbar at the top of the Query window in the Management Studio, as shown in Figure 3-1.<br />

Figure 3-1<br />

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

INFORMATION_SCHEMA is a special access path that is used for displaying metadata<br />

about your system’s databases and their contents. INFORMATION_SCHEMA has several<br />

parts that can be specified after a period, such as INFORMATION_SCHEMA.SCHEMATA<br />

or INFORMATION_SCHEMA.VIEWS. These special access paths to the metadata of your<br />

system have been put there so you won’t have to use system tables.<br />

45

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

Saved successfully!

Ooh no, something went wrong!