Click here to Skip to main content
12,997,531 members (58,711 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 23 Nov 2011

General rules on selecting Data Types of SQL Server

, 23 Nov 2011
Rate this:
Please Sign up or sign in to vote.
1.Use the smallest possible columnsizes. The smaller the columnsize, the less the amount of data that SQL Server has to store and process, and the faster SQL Server will be able to read and write the data. In addition, the narrower the column, the faster a sort will be performed onthat column.

2.Use the smallest possible data type that will hold your data for a column. For example, if you are going to be storing numbers from 1 to 99 in a column, you would be better off selecting the TINYINT data type instead of the INT data type.
For numeric data, it is better to use a numeric data type such as INTEGER rather than using VARCHAR or CHAR, since numeric data types generally require less space to hold numeric values then character data types. Also, if numeric data is stored as characters, it will have to be converted to numbers to be used in calculations. Smaller columns can improve performance when the columns are searched, joined with other columns, or sorted.

3.FLOATs or REALs should not be used to define primary keys. Integer data types are most commonly used for primary keys. Avoid selecting the fixed-length columns—CHAR or NCHAR—if your columnwill have a lot of NULLs. The NULL ina CHAR or NCHAR field will take up the entire fixed length of 255 characters. This is a large waste of space and reduces SQL Server’s overall performance.

4.If you are going to be using a column for frequent sorts, consider an integer-based column rather than a character-based column. SQL Server sorts integer data faster than character data.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ahmed Naqibul Arefin
Software Developer
Bangladesh Bangladesh
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170622.1 | Last Updated 23 Nov 2011
Article Copyright 2011 by Ahmed Naqibul Arefin
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid