I wonder about the difference between different data types in SQL Server to store strings.
For example ntext, nvarchar(X), varchar, nvarchar(max) etc.
What could be the advices in terms of flexibility, resource usage and performance?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
All the string types the
Nare unicode – 2 bytes for each characters, will store things like Cyrillic, Asian, Arabic, Hebrew alphabets – while those without the leadingNare not unicode (only properly store Western European / ASCII characters)TEXTandNTEXTare deprecated – don’t use those anymore – use(N)VARCHAR(MAX)instead – see the relevant MSDN documentation on that topic for detailsNVARCHAR(X)is a “normal” string, max. of 8000 bytes of data (4000 Unicode or 8000 non-Unicode characters) – stored in the regular page in SQL ServerNVARCHAR(MAX)is a special type, up to 2 GB of storage (1 billion Unicode characters) – but it requires special handling in storage, more effort needed, performs a bit slower than regular strings; use only when absolutely needed