Tuesday, June 10, 2014

Data types in SQL Server



Data Types In SQL Server


Category
Data Type
Bytes
Rannge
Integer
Tiny int
1
0 To 255

Small int
2
-32768 To 32767

Int
4
-2147483648 To 2147483647

Big int
8
-263 To 263 – 1
Float
Decimal(P,S)
5 to 17
Decimal(7,2) will allow a total of 7 digits where 2 digits will be after the decimal point. (ex : 12345.67)

Float(P)
If P<25  4 Bytes
If P>=25 8 Bytes


Small Money
4 Byte Decimal


Money
8 Byte Decimal

Character
Char (n)

Fixed Length Char Data and n can be up to maximum 8000

Varchar(n)

Variable Length Char Data And n Can be up to maximum 8000

NChar(n)
a Unicode character will occupy 2 bytes in memory
Fixed Length Unicode char data and n can be up to maximum 4000.

Nvarchar(n)

Variable Length Unicode char data and n can be up to maximum 4000.

Text(n)
n can be up to maximum 2GB
Variable length char Data

Ntext(n)
N can be up to maximum 230 – 1
Variable length Unicode char data
Binary
Binary(n)
N can be up to maximum 8000
Fixed length binary data

VarBinary(n)
N can be up to maximum 8000
Variable Length Binary Data

Image(n)
N can be up to maximum 231 – 1
Variable Length Binary data

Bit
1
True/False/NULL
Large Objects
Varchar(Max)
231 – 1
Variable Length Char Data

NVarchar(Max)
231 – 1
Variable Length Unicode Char Data

VarBinary(Max)
231 – 1
Variable Length Binary Data
DateTime
SmallDatetime
2
Jan 1st 1900 to june 6th 2079

DateTime
4
Jan 1st 1753 to Dec 31st 9999
Miscellaneous
SQL_variant
Size varies
Can Store any Type of Data

Table
Size varies
Can Store a Table

XML
Size Varies
Can store XML documents

Thanks
GSV

No comments: