Using T-SQL to Create Tables

Ultimately, all the tables created with the visual tools can also be created by using T-SQL. As with many of the SSMS tools, database objects can be resolved or scripted into T-SQL statements. Let’s examine the T-SQL syntax to better understand some of the table creation options; then we can discuss the definition of the columns in each table.

The full T-SQL CREATE TABLE syntax is extensive. It includes options to define table constraints, indexes, and index options. The SQL Server Books Online topic named “CREATE TABLE (Transact-SQL)” shows the full syntax and describes each of these options in detail. Listing 21.1 shows the basic T-SQL syntax; the first part of the syntax is listed in Books Online. This syntax is ...

Get Microsoft SQL Server 2014 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.