Advertisement
Beginner SQL Server, Data Types & Schema Design

What are the most commonly used data types in SQL Server, and when would you use each one?

Short answer

INT is used for whole numbers like an id or a count, VARCHAR stores variable length text like names or descriptions, DECIMAL is used for precise numbers like currency where rounding errors matter, and DATETIME or DATE store date and time values, with the right choice depending…

Save SQL Server mock interview
Advertisement
AModel answer
INT is used for whole numbers like an id or a count, VARCHAR stores variable length text like names or descriptions, DECIMAL is used for precise numbers like currency where rounding errors matter, and DATETIME or DATE store date and time values, with the right choice depending on exactly what kind of data a column needs to hold.
CREATE TABLE Products (
  ProductId INT PRIMARY KEY,
  Name VARCHAR(100),
  Price DECIMAL(10,2),
  CreatedDate DATETIME
);
Real-world example
A product catalog carefully chooses DECIMAL instead of a floating point type for storing prices, avoiding subtle rounding errors that could otherwise cause small but noticeable mistakes in financial calculations.
Likely follow-ups
  • Why should DECIMAL be preferred over FLOAT for storing currency values?
  • What is the difference between CHAR and VARCHAR?
Related topics