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 8: Being Normal: Normalization and Other Basic Design Issues<br />

Figure 8-11<br />

That’s because our table exists only as an edited item on the diagram — it won’t be added until we actually<br />

save our changes.<br />

If you look at the CustomerNotes table in the diagram window at this point, you<br />

should see a * to the right of the name — that’s there to tell you that there are unsaved<br />

changes in that table.<br />

Now, switch back to the Management Studio. There are two save options:<br />

❑ Save: This saves the changes to both the diagram and to the database (this is the little disk icon<br />

on the toolbar).<br />

❑ Generate Change Script: This saves the changes to a script so it can be run at a later time. (This<br />

is found in the Table Designer menu or as an icon on the Table Designer toolbar.<br />

The Table Designer toolbar contains several smart icons that provide quick access to<br />

many frequently used table design features. Unfortunately, it does not come up by<br />

default in the designer under the RTM version of <strong>SQL</strong> <strong>Server</strong> <strong>2008</strong>. You can add it by<br />

right-clicking open space in the toolbar and selecting the Table Designer toolbar.<br />

Go ahead and just choose Save, and you’ll be prompted for the name of your diagram and confirmation<br />

(after all, you’re about to alter your database — there’s no “undo” for this).<br />

Confirm the changes, and try running that query again against your CustomerNotes table. You should<br />

not receive an error this time because the table has now been created. (You won’t get any rows back, but<br />

the query should still run.)<br />

How It Works<br />

When we create a diagram, <strong>SQL</strong> <strong>Server</strong> creates script behind the scenes that looks basically just as our<br />

scripts did back in Chapter 6 when we were scripting our own changes. However, these scripts are not<br />

actually generated and run until we choose to save the diagram.<br />

239

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

Saved successfully!

Ooh no, something went wrong!