Choosing the Right SQL Server Data Types (and Why It Matters for Performance)
Data types feel like a minor detail when you create a table, and they are expensive to change once the table holds millions of rows. The right types make rows smaller, so more fit in memory, indexes shrink, and queries read less. The wrong ones cause subtle bugs, implicit conversions and wasted memory grants. Text: VARCHAR vs NVARCHAR NVARCHAR stores Unicode, so it handles any language, at about 2 bytes per character for most text. VARCHAR uses 1 byte per character for characters in its code page. From SQL Server 2019, a UTF-8 collation lets VARCHAR store Unicode too, which can save space for mostly-English text. Use NVARCHAR for names, addresses and free text that may contain any language. Use VARCHAR for codes you control, such as EmployeeCode , country codes or status values. Match the type in your application parameters. Comparing a VARCHAR column with an NVARCHAR parameter can force a conversion and an index scan. Realistic lengths, not MAX Do not declare every string as ...