Tuesday, July 13, 2010

DataType

DATATYPE



DataType
Storage Size (Bytes)
Values
Comment
Tinyint
1
0 to 255
Smallint
2
-2 x to 2 x - 1
(X: 15)
Int
4
-2 x to 2 x - 1
 (X: 31)
Bigint
8
-2 x to 2 x - 1
 (X: 63)
Numeric
5 to 17
Datetime
8
01/01/1753 to 12/31/9999
Accuracy: 3 miliseconds
smalldatetime
4
01/01/1900 to 06/06/2079
Accuracy: 1 minute
Datetime2
6 to 8
01/01/0001 to 12/31/9999
Accuracy: 100 nanoseconds
datetimeoffset
8 to 10
01/01/0001 to 12/31/9999
Accuracy: 100 nanoseconds
Date
3
01/01/0001 to 12/31/9999
Accuracy: 1 Day
Time
3 to 5
00:00:00.0000000 to
23:59:59.9999999
Accuracy: 100 nanoseconds
Char
As specified
Only english characters are allowed
Text
generally not used now
Varchar
as specified
max 2 GB
Only english characters are allowed
Nchar
As specified
(double the char)
Non-english characters are allowed
Ntext
generally not used now
Nvarchar
as specified
(double the varchar)
max: upto 2 GB
Can store non-english characters
Binary
As specified
Varbinary
Variable As specified
max: upto 2 GB
FILESTREAM can be used with VARBINARY(MAX)
Image
16
generally not used now
Cursor
Hierarchyid
892 bytes
Binary number maintains the
hierarchy
sql_variant
timestamp/
rowversion
nullable : varbinary(8)
non-nullable: binary(8)
Unique Binary number
throught database
uniqueidentifier
16
NEWID function can be used
Xml
max: upto 2 GB
Maximum 128 levels
Geography
max: upto 2 GB
Geometry
max: upto 2 GB

User Defined Data Types:
CREATE TYPE City FROM VARCHAR(255) NOT NULL
CREATE TABLE Info (INT, B CITY)

No comments:

Post a Comment