You are on page 1of 1

/* CREATE Table:Create table is the command to create any table object in sql server and It will

create only structure Syntax: Create Table anyname (Columnname Datatype,Columnname


Datatype,..) */ create table [FirstTable]([Id] int,[Product Name] varchar(15)) select * from
[FirstTable] /*===================================Data
Types=========================== Exact Numerics: Exact Numerics are like
TINYINT,SMALLINT,INT,BIGINT,NUMERIC,DECIMAL,BIT,MONEY and SMALLMONEY
TINYINT,SMALLINT,INT,BIGINT: These datatypes will allow numeric values TINYINT: It will
allows only numeric values . Range is 0-255 and storage is 1 byte */ create table [TinyInt]( Id
tinyint) Insert into [TinyInt] values(1)--Executed select * from [TinyInt] Insert into [TinyInt]
values(-25)--Error. Not in the range Insert into [TinyInt] values(270)--Error. Not in the range
Insert into [TinyInt] values(25.67)--Executed. only before decimal value is inserted select * from
[TinyInt] Insert into [TinyInt] values('xyz')--Error. It will allows only numeric values /* SMALLINT: It
will allows only numeric values . Range is -32767 to 32768 and storage is 2 byte */ Create table
[SmallInt](ProductID smallint) Insert into [SmallInt] values(-25)--Executed Insert into [SmallInt]
values(25)--Executed select * from [SmallInt] Insert into [SmallInt] values(32769)--Error. Not in
the range Insert into [SmallInt] values(356.789)--Executed.only before decimal value is inserted
select * from [SmallInt] /*INT:It will allows only numeric values . Range is -2147483647 to
2147483648 and storage is 4 byte */ create table [Int](Productid Int) Insert into [Int]
values(-214.76)--Executed.Only before decimal values only inserted Insert into [Int]
values(842947) select * from Int Insert into [Int] values(9998345221)--Error. Not in the range /*
BIGINT: It will allows only numeric values . Range is -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807 and storage is 8 byte */ Create table [Bigint](id bigint) Insert into
[Bigint] values(-2764732634)--Executed Insert into [Bigint] values(2345.678)--Executed Insert
into [Bigint] values(9998345221)--Executed select * from [Bigint] /* COMMENTS: SQL server
can't recognise the text in the comment There are 2 types of COmments 1) Single Line
comment 2) Multi Line Comment 1) Single Line comment: In a particular line what ever you write
sql server can't executed .Single line comment you have to mention 1 dashe like -- 2) Multi Line
Comment: Multiple lines of text sqlserver can't executed. Multiple line comment are mention like
/* */ */ --dajsdlkjaslfkjaslkfjask /* ldskjalksdfjlkasjfdlksajf jdlkjaslkdfjalkdjf dkjalksfjdlkajfdksajflk
dkjflkajsdflkj */ /* BIT:It will allows only either 0,1 and NULL */ Create table [BIT](id bit) Insert into
[BIT] values(1) Insert into [BIT] values(0) select * from [BIT] Insert into [BIT] values(25) Insert
into [BIT] values(-25) Insert into [BIT] values(-25.67) Insert into [BIT] values(null)

You might also like