How to Create Table In SQL Server
SQL CREATE TABLE Statement,Create a New Table in SQL Server
![]() |
Create table In SQL Server |
Friends in previous post we learned about how to create database in SQL server using SQL Query and using GUI. in this post we are going to learn how to create table in SQL Server.like a database you can also create table using two different methods in SQL Server, using SQL Query and using GUI. lets see-
Create Table In SQL Server Using SQL Query
Open SQL server management studio.
Then select on "New Query" Option, or simply press the shortcut key "Cttrl + N".
then select your database in which you want to create table. to select specific database type following SQL Query
syntax:
use database_name
(Note: in place of database_name type your database name in which you want to create a new table.)
for ex. use students
after executing above command you will see the your database name in available database name in box.
now to create table type following command
syntax:
create table table_name
( coluumn name datatype(size),
coluumn name datatype(size),
.
.
.
coluumn name datatype(size)
)
for Example
create table class2
( sr_no int,
stu_name varchar(10),
stu_age int
)
that's done your table will be created in your selected database.
Create Table In SQL Server Using GUI
you can also create table in SQL server using GUI. lets see-
Open the SQL Server management studio
Then Expand the database option available on left hand side.
you will see the list of available databases. now expand database in which you want to create table.
Now you will see the "Table" option right click on it
select "Table" from drop down.
now a table format will be open look like this-
fill the information column name,datatype and allow null as you want.
you can also change the table properties from properties window available at right side.
Then press CTRL + S to save the table. if you didn't give name for your table it will ask for table name. type table name and press OK. that's done your table is ready.
If you still have any problem how to create table in SQL please ask us through the comment box.
Post a Comment