SQL Server: How to create a table
In this article i will explain how to create a table in SQL Server.
create table <table-name> ( <column-name> <data-type>, <column-name> <data-type>, ... )
Now we will create a Employee table.
create table Employee ( EmpNo int, EmpName varchar(20), EmpSalary decimal )
Write the above query and press F5 or click Execute button as shown below.
Now we will get following message at the bottom of the window.
"Command(s) completed successfully."
This means your table created successfully.
Now we will check wethere Employee table is create or not? Run the following query so that you will get table related details.
Exec sp_help 'Employee'
In the above query sp_help is a procedure and you are passing Employee table name as parameter. Pass table name in single quotes. After executing the above query you will get table realted full information like table name, columns list, and other details. See the following output you will find table details.
CreatedSep 05, 2013
UpdatedSep 05, 2013