NVarchar (MAX) for short strings

I am interested in the fact that NVarchar (MAX) is a good data type. I want to store short unicode strings 1-50 characters long, but most of them (over 90%) are 5-10 characters long?

The column will not be used to compare and organize queries. It can be added to the index as an included column. The number of expected rows is more than 10 M.

Any recommendations? Thank you in advance!

+3
source share
3 answers

Why are you using nvarchar (MAX) for such short lines? If you know that the maximum length is 50 characters, make it nvarchar (50).

, , nvarchar (MAX) , 900 .

+6

, nvarchar (50) , 50.

+1

NVARCHAR (MAX) (which I assume is the same as NTEXT in earlier versions of SQL Server) is designed to store long text values โ€‹โ€‹of a variable and potentially unlimited length.

If you know that the values โ€‹โ€‹will not exceed N characters, you should use NVARCHAR (N).

+1
source

Source: https://habr.com/ru/post/1714330/


All Articles