SQL Server – CREATE a Table

Tables are the basic building block of any database. Every DBA has to create tables in a database, many times even Programmers needs create table in database.

In SQL Server 2005, you can create tables either by using Graphical method or by T-SQL code.

We will create a simple CUSTOMER table using both the methods

Using T-SQL code:

Type the following code in Query window and execute it.

/* — To create a Customer table — */

CREATE TABLE Customer (

CustID INT NOT NULL,

LastName VARCHAR(25) NOT NULL,

FirstName VARCHAR(20),

Address VARCHAR(50),

Phone VARCHAR (15)

);

Using Table creation Wizard:

Open SQL Server Management Studio, expand the server tree, right click on Tables folder -> New Table.

Enter the column details as shown below:

Customer Table

Customer Table

Save the table before closing the table tab.

A database will have many tables as per the project requirements.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: