Question

I am interested is NVarchar(MAX) a good data type is I want to store short unicode strings which are 1-50 characters long, but most of them (more than 90%) are 5-10 characters long?

The column will not be used in comparison and ordering queries. It might be added to index as included column. Expected rows count - more than 10M.

Any recommendations? Thank you in advance!

Was it helpful?

Solution

Why would you use nvarchar(MAX) for such short strings? If you know the maximum length is 50 characters, make it nvarchar(50).

Also, I do not believe an nvarchar(MAX) column can be included in an index as it would break the 900 byte limit.

OTHER TIPS

I would suggest that nvarchar(50) is more appropriate if the maximum length is indeed 50.

NVARCHAR(MAX) (which I believe is the same as NTEXT in the earlier versions of SQL server) is intended for storing long text values of variable and potentially unlimited length.

If you know the values won't exceed N characters, you should use NVARCHAR(N).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top