Understanding SQL Server data types
The conceptual data model we have created thus far defines what tables a database consists of. Also, it tells you all the columns that form each table. For instance, a table called Product
may contain the ProductName
, ListPrice
, Category
, and EndDate
columns. Before we can actually create this table, we need to know what sort of values each column will contain. In other words, we need to choose an appropriate data type. The data type of a column determines three things:
- Which types of values can be stored in the column. Can you store numbers, such as product prices, or dates, such as transaction dates?
- What computations or manipulations you can do with the data. For example, you can add two numbers together, but you cannot multiply two dates.
- The efficiency of both data storage and data manipulations. Some data types are smaller than others, making them more efficient to store and work with.
Choosing the proper data type is...