Lesson 27. Creating Tables

You can use SSMS to create, modify, and drop tables. However, after a while, you will discover that SSMS can be kind of clunky to deal with and writing code for these tasks is much faster.

I use a combination of both. I use T-SQL to do basic table creation. Then I will use SSMS to do things like adding keys, indexes, and relationships.

CREATE TABLE Syntax

In [ ]:

CREATE TABLE [table name]
[column 1] [data type] [NULL|NOT Null],
[column 2] [data type] [NULL|NOT Null],
[column 3] [data type] [NULL|NOT Null]
)

Examples

A Simple Table Creation Example

In [ ]:

USE demo

CREATE TABLE Person(
PersonID BIGINT NOT NULL,
FirstName NVARCHAR(50) NULL,
LastName NVARCHAR(50) NULL,
)

Last updated