SQL Server Interview Question #23

What is the difference between VARCHAR and NVARCHAR?

Data Types, Keys & Constraints Junior Beginner

Detailed Explanation

VARCHAR stores non-Unicode character data using the database/collation code page, while NVARCHAR stores Unicode data using UTF-16 encoding in SQL Server.

NVARCHAR is appropriate when the application must reliably store multilingual text such as Urdu, Arabic, Chinese, or mixed-language content. String literals intended as Unicode should normally use the N prefix.

NVARCHAR can require more storage than VARCHAR for many character sets, so the choice should reflect the actual data requirements.

Code Example

DECLARE @Text NVARCHAR(100) = N'السلام علیکم';

SELECT @Text;