Creating table in SQL Server

You can create table in MS SQL Server either of the following way,
•Enterprise Manager
•Transact SQL (T-SQL) statement

Here I will show you how to create table using T-SQL. The syntax is as below for creating table,



Below is an example of create a table

Once table is created you can modify the table. Add new column, drop exsiting column and alter exsiting column data type. The syntax for modifying a table using T-SQL is (syntax shows how to add new column),

In the example below we will modify the Airlines Master table and add a new column,

To change the datatype of a column the example is as follow,

In the example below we will change the Country column of Airline Master table data type from Int to Varchar,

To drop a column from a table the syntax and example is below,

 

 

Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

*