Data Types in Microsoft SQL Server


When working with SQL Server, one of the first things you need to understand is data types in Microsoft SQL Server. Every column in a table needs a data type. It tells SQL Server what kind of data the column will store (e.g. text, numbers, or dates).

In this post, I’ll explain what are the data types in SQL Server, share a practical SQL Server data types list with examples, and show you how to create a table using different data types in one go.

What Are the Data Types in Microsoft SQL Server?

In SQL Server, a data type defines what kind of data you can store in a column or variable. Choosing the right data type helps SQL Server store and process your data more efficiently.

For example:

  • Use text data types for names or addresses.
  • Use numeric data types for prices or quantities.
  • Use date/time data types for order dates or timestamps.

Now, let’s look at some examples.

SQL Server Data Types List with Examples

Here’s a simple SQL Server data types list with examples that you’ll use regularly when creating tables or working with data.

1. String (Text) Data Types

Data TypeDescriptionExample
VARCHAR(n)Variable-length text‘I Am Mika’
NVARCHAR(n)Unicode text (multi-language)‘北京’
CHAR(n)Fixed-length text‘USA’
TEXTLarge text (older type)Long descriptions

Tip: Use NVARCHAR if you need to store special characters or multiple languages.

2. Numeric Data Types

Data TypeDescriptionExample
INTWhole numbers1000
BIGINTLarge whole numbers1000000000
DECIMAL(p,s)Precise decimals (for money)26.06
NUMERIC(p,s)Same as DECIMAL1986.14
FLOATApproximate decimals12.3456

Tip: Use DECIMAL or NUMERIC when you need exact numbers (e.g. for financial amounts).

3. Date and Time Data Types

Data TypeDescriptionExample
DATEDate only‘2025-06-26’
TIMETime only’14:30:00′
DATETIMEDate and time combined‘2025-06-26 14:30:00’
DATETIME2More precise date and time‘2025-06-26 14:30:00.1234567’

4. Other Useful Data Types

Data TypeDescriptionExample
BITBoolean (0 or 1)1 (True), 0 (False)
UNIQUEIDENTIFIERGlobally unique ID550e8400-e29b-41d4-a716-446655440000

Example: Creating a Table Using Different Data Types

To make things more clear, here’s a real-world example of how you can create a table using different SQL Server data types together. Let’s say that, before we create orders for our customers, we need to give them quotes/offers. For this example, we will create a new table that holds information about the offers:

CREATE TABLE Quotes (
    QuoteID INT PRIMARY KEY,
    CustomerName VARCHAR(100),
    CustomerAddress NVARCHAR(200),
    QuoteDate DATETIME,
    TotalAmount DECIMAL(10, 2)
)

What this does:

  • QuoteID: A unique number for each quote/offer.
  • CustomerName: Stores names as regular text.
  • CustomerAddress: Stores addresses using Unicode (good for multi-language data).
  • QuoteDate: Records when the offer was placed.
  • TotalAmount: Stores the total price with two decimal places, suitable for currency.

Here is what it looks like in SSMS:

Data Types in Microsoft SQL Server

Using the right data types like this makes your database easier to manage and keeps your data accurate.

Choosing the Right Data Type

Here’s a quick guide:

  • Use VARCHAR or NVARCHAR for text.
  • Use INT for whole numbers unless you expect very large values.
  • Use DECIMAL for prices or precise values.
  • Use DATETIME2 for date and time tracking.

Choosing the right data type from the start helps SQL Server handle your data better and saves space.

Also, make sure you check my previous SQL blog post on XXXXXXXXXX? And if you want to learn more about MS SQL Server data types, visit this page by Microsoft.

If you would like to learn more about programming SQL queries, make sure you buy this book: T-SQL Fundamentals (Developer Reference)


Add a Comment

Your email address will not be published. Required fields are marked *