T-SQL reference › varchar vs nvarchar
varchar vs nvarchar in SQL Server
varchar stores non-Unicode text. nvarchar stores Unicode (N for national). If a name can have accents or other scripts, nvarchar is the one that will not turn them into question marks.
How they look
SELECT CAST('Becky' AS varchar(20)) AS ascii_name,
CAST(N'Sandrá' AS nvarchar(20)) AS unicode_name;
The N before a string literal means “this is Unicode.” Miss it and a nvarchar comparison can do extra conversions.
At work
- Names, addresses, free text:
nvarchar. - Codes you control (status, SKU):
varcharis fine. nvarchar(max)for a dump, not for a column you filter on all day.
varchar(1) for a flag
Use char(1) or a bit. Do not store Yes/No as a long string if a bit will do.
Try it on Harbour & Co
Amy Nair (Finance Lead) needs this now: “Mailing list for the newsletter. Some names have stray spaces and emails have capitals. Clean it, no duplicates.” Write the query, run it, send the results. On the paid plan.
Take the ticket →Learn it on a real ticket
Monday is free on WorkSQL. A colleague’s ticket lands, you write the T-SQL, we mark it. No videos. Five minutes.
Clock in free See Monday’s tickets