dev.rean.me
database

08 - SQL Server vs MySQL Data Types (Video in Khmer)

Compare common SQL Server and MySQL data types for numbers, text, and dates, with simple examples, practical tips, and a video lesson.

2026-08-27 ยท 3 min read

Share:

Hello my friend! In this lesson, we compare common data types in Microsoft SQL Server and MySQL. Both databases store numbers, text, and dates, but some type names and details are different.

What is a data type?

A data type tells the database what kind of value a column can store. For example, a column may store a number, text, or a date.

Common data types

UseSQL ServerMySQLExample
Whole numbersINTINT25
Exact decimal numbersDECIMAL(p,s)DECIMAL(p,s)19.99
Variable-length textVARCHAR(n)VARCHAR(n)'Hello'
Unicode textNVARCHAR(n)VARCHAR(n) with a suitable character set'Hello'
Date onlyDATEDATE'2026-10-24'
Date and timeDATETIME2DATETIME or TIMESTAMPDepends on the type and database

These are common examples, not a complete list. The maximum lengths, supported types, and behavior can differ by database and version.

Example

This SQL Server table uses NVARCHAR for Unicode text and DATETIME2 for a date and time:

CREATE TABLE Products (
  ProductID INT PRIMARY KEY,
  ProductName NVARCHAR(100) NOT NULL,
  Price DECIMAL(10, 2),
  CreatedAt DATETIME2
);

In MySQL, a similar table could use VARCHAR with a Unicode character set and DATETIME:

CREATE TABLE Products (
  ProductID INT PRIMARY KEY,
  ProductName VARCHAR(100) NOT NULL,
  Price DECIMAL(10, 2),
  CreatedAt DATETIME
) CHARACTER SET utf8mb4;

Watch the Video

This video explains data types in SQL Server and MySQL. The video is in Khmer.

Tips

  • Choose a data type that matches the values you need to store.
  • Use DECIMAL for exact values such as prices; do not use floating-point types when exact decimal values are required.
  • Check how your database stores text and supports Unicode, especially when storing Khmer or other languages.
  • Check the database documentation before converting data types or moving data between systems.
  • Test with realistic sample data so you can catch values that do not fit.