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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 10: Views<br />

314<br />

There are four panes to the View Builder — each of which can be independently turned on or off:<br />

❑ The Diagram pane<br />

❑ The Criteria pane<br />

❑ The <strong>SQL</strong> pane<br />

❑ The Results pane<br />

For those of you who have worked with Access at all, the Diagram pane works much as it does in Access<br />

queries. You can add and remove tables, and even define relationships. Each of those added tables, checked<br />

columns, and defined relationships will automatically be reflected in the <strong>SQL</strong> pane in the form of the <strong>SQL</strong><br />

required to match the diagram. To identify each of the icons on the toolbar, just hover your mouse pointer<br />

over them for a moment or two, and you will get a ToolTip that indicates the purpose of each button.<br />

You can add tables either by right-clicking in the Diagram pane (the top one in<br />

Figure 10-2) and choosing Add Table or by clicking on the Add Table toolbar button<br />

(the one with an arrow pointing right in the very top left of the icon).<br />

Now select some columns, as shown in Figure 10-3.<br />

Figure 10-3<br />

Note that I am just showing the diagram pane here to save space. If you have the Grid pane up while<br />

you check the above, then you would see each column appear in the Grid pane as you select it. With the<br />

<strong>SQL</strong> pane up, you will also see it appear in the <strong>SQL</strong> code.<br />

In case you haven’t recognized it yet, we’re building the same view that we built as our first complex<br />

view (CustomerOrders_vw). The only thing that’s tricky at all is the computed column (TotalDiscount).<br />

To do that one, either we have to manually type the equation into the <strong>SQL</strong> pane, or we can type<br />

it into the Column column in the Grid pane along with its alias (see Figure 10-4).

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

Saved successfully!

Ooh no, something went wrong!