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
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
| Use | SQL Server | MySQL | Example |
|---|---|---|---|
| Whole numbers | INT | INT | 25 |
| Exact decimal numbers | DECIMAL(p,s) | DECIMAL(p,s) | 19.99 |
| Variable-length text | VARCHAR(n) | VARCHAR(n) | 'Hello' |
| Unicode text | NVARCHAR(n) | VARCHAR(n) with a suitable character set | 'Hello' |
| Date only | DATE | DATE | '2026-10-24' |
| Date and time | DATETIME2 | DATETIME or TIMESTAMP | Depends 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
DECIMALfor 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.