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.

City varchar(20) NOT NULL,<br />

State char(2) NOT NULL,<br />

Zip char(5) NOT NULL<br />

);<br />

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

CREATE TABLE Sales<br />

(<br />

OrderNumber varchar(20) NOT NULL PRIMARY KEY,<br />

StoreCode char(4) NOT NULL<br />

FOREIGN KEY REFERENCES Stores(StoreCode),<br />

OrderDate date NOT NULL,<br />

Quantity int NOT NULL,<br />

Terms varchar(12) NOT NULL,<br />

TitleID int NOT NULL<br />

);<br />

Most of the inserts we’re going to do in this chapter will be to the Stores table we just created, so let’s<br />

review the properties for that table. To do this, expand the Tables node of whichever database was current<br />

when you ran the preceding script (probably AdventureWorks given the other examples we’ve<br />

been running) in the Object Explorer within the Management Studio. Then expand the Columns node as<br />

shown in Figure 3-3.<br />

Figure 3-3<br />

In this table, every column happens to be a char or varchar.<br />

69

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

Saved successfully!

Ooh no, something went wrong!