0% found this document useful (0 votes)
6 views

SQL Server Data Types

Uploaded by

suresh p
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

SQL Server Data Types

Uploaded by

suresh p
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL Server Data Types

1. SQL Server String Data Type

char(n) It is a fixed width character string data type. Its size can be up to 8000
characters.

varchar(n) It is a variable width character string data type. Its size can be up to
8000 characters.

varchar(max) It is a variable width character string data types. Its size can be up to
1,073,741,824 characters.

text It is a variable width character string data type. Its size can be up to 2GB
of text data.

nchar It is a fixed width Unicode string data type. Its size can be up to 4000
characters.

nvarchar It is a variable width Unicode string data type. Its size can be up to 4000
characters.

ntext It is a variable width Unicode string data type. Its size can be up to 2GB
of text data.

binary(n) It is a fixed width Binary string data type. Its size can be up to 8000
bytes.

varbinary It is a variable width Binary string data type. Its size can be up to 8000
bytes.

image It is also a variable width Binary string data type. Its size can be up to
2GB.
2. SQL Server Numeric Data Types

bit It is an integer that can be 0, 1 or null.

tinyint It allows whole numbers from 0 to 255.

Smallint It allows whole numbers between -32,768 and 32,767.

Int It allows whole numbers between -2,147,483,648 and 2,147,483,647.

bigint It allows whole numbers between -9,223,372,036,854,775,808 and


9,223,372,036,854,775,807.

float(n) It is used to specify floating precision number data from -1.79E+308 to


1.79E+308. The n parameter indicates whether the field should hold the
4 or 8 bytes. Default value of n is 53.

real It is a floating precision number data from -3.40E+38 to 3.40E+38.

money It is used to specify monetary data from -922,337,233,685,477.5808 to


922,337,203,685,477.5807.

3. SQL Server Date and Time Data Type

datetime It is used to specify date and time combination. It supports range from
January 1, 1753, to December 31, 9999 with an accuracy of 3.33
milliseconds.

datetime2 It is used to specify date and time combination. It supports range from
January 1, 0001 to December 31, 9999 with an accuracy of 100
nanoseconds

date It is used to store date only. It supports range from January 1, 0001 to
December 31, 9999

time It stores time only to an accuracy of 100 nanoseconds

timestamp It stores a unique number when a new row gets created or modified.
The time stamp value is based upon an internal clock and does not
correspond to real time. Each table may contain only one-time stamp
variable.
4. SQL Server Other Data Types

Sql_variant It is used for various data types except for text, timestamp, and
ntext. It stores up to 8000 bytes of data.

XML It stores XML formatted data. Maximum 2GB.

cursor It stores a reference to a cursor used for database operations.

table It stores result set for later processing.

uniqueidentifier It stores GUID (Globally unique identifier).

You might also like