SQL Server Data Types

by Kareem Allam 4. November 2011 19:00

Data Type

Size

Range

TINYINT(n)

1 byte

0 to 255 (unsigned)

SMALLINT(n)

2 bytes

-32,768 to 32,767

INT(n)

4 bytes

Approximately plus or minus 2 billion (-2,147,483,648 to 2,147,483,647)

BIGINT(n)

8 bytes

Approximately plus or minus 10 billion billion or 10 million trillion or 10 thousand quadrillion or 10 quintillion (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)

FLOAT(n)

4 bytes if n < 25 or 8 bytes if 24 < n < 54

n decimal places

REAL

4 bytes

 

DECIMAL(n,d)

5 to 17 bytes

n digits before and after the decimal point, d decimal places

SMALLMONEY

4 bytes

-214,748.3648 to 214,748.3647

MONEY

8 bytes

-922,337,203,685,477.5808 to 922,337,203,685,477.5807

SMALLDATETIME

4 bytes

01/01/1900 00:00 to 06/06/2079 23:59

DATETIME

8 bytes

01/01/1753 to 31/12/9999

DATETIME2

6 to 8 bytes

01/01/0001 to 31/12/9999. Intended as a replacement for SMALLDATETIME and DATETIME

DATETIMEOFFSET

8 to 10 bytes

01/01/0001 to 31/12/9999, includes space for timezone offset

DATE

3 bytes

01/01/0001 to 31/12/9999

TIME

3 to 5 bytes

Accurate to 100 nanoseconds

CHAR(n)

fixed length, 1 byte per character (n), up to 8000

Consumes n bytes of storage

NCHAR(n)

2 bytes per field length (n)

Stores unicode characters

VARCHAR(n)

variable length, 1 byte per character (n), up to 8000

Consumes 1 byte per character stored, up to n bytes

VARCHAR(MAX)

2 bytes per character stored

Maximum 2GB. Replacement for TEXT datatype

NVARCHAR(n)

2 bytes per character stored (n), up to 4000

Stores unicode characters

NVARCHAR(MAX)

2 byte per character stored

Maximum 2GB. Replacement for NTEXT datatype

BIT

1 bit

Null, 0 or 1

BINARY

Fixed width binary data

Up to 8000 bytes

VARBINARY

Variable width binary data

Up to 8000 bytes

VARBINARY(MAX)

Variable width binary data

Up to 2GB

XML

Stores XML documents

XML Schema collection can be defined to verify documents

If you enjoyed this post, make sure you subscribe to my RSS feed!

Comments (9) -

lose weight fast
lose weight fast United States
11/16/2011 12:34:58 AM #

For so many unique ideas on the internet, this is one extra that I harmonised. Thanks for sharing.

Sherita Licano
Sherita Licano United States
11/22/2011 7:32:45 AM #

I feel  this  internet site  has got  some  very   excellent  information   for everybody : D.

Haley Maharg
Haley Maharg United States
11/22/2011 3:30:59 PM #

Very informative stuff! We need to get our company listed on Google maps and will be giving you a shout as soon as our website is up.

Divina
Divina United States
11/23/2011 8:26:18 PM #

I wanted to thank you for this excellent read!! I definitely enjoyed every little bit of it. I have you bookmarked your site to check out the latest stuff you post.

Patricia
Patricia United States
12/6/2011 11:52:57 AM #

The blog looks good. Maybe improving the website design will make it look more professional and earn you more followers. Keep up the good work!

Web Design Dubai
Web Design Dubai U.A.E.
2/8/2012 7:44:36 AM #

This is my first opportunity to visit this website. I found some interesting things and I will apply to the development of my blog. Thanks for sharing useful information.

SJR Builders Developers
SJR Builders Developers United States
3/28/2012 1:06:25 PM #

Thank you for sharing this.

Tomas
Tomas
6/6/2012 1:50:36 AM #

Very well said. Youve revealed an element I had not thought of before this and I am in your debt for that!

Janice
Janice
6/26/2012 5:57:54 PM #

While I am examining this post, I am getting so much information there. Thanks a lot for expressing your thoughts and ideas here!

About EgDev.com

If you would like to find value services with excellent quality and cost effectiveness and with a focus on speed , Just Follow

 Egypt Development Freelance Team.

Month List

Page List