SQL Server 2005+ equivalent
The best SQL type equivalent to C # String is nvarchar(max) . It stores exactly the same amount of text as an instance of a C # String object. But be careful. Choosing other types of [n][var]char would be more optimal in the data warehouse (that is, they could work much faster), but choosing one of them depends largely on the data you want to save.
char(n) is for strings of fixed length (length n), so if your strings are not different in size, you should choose this type (for example, product keys)varchar(n) used for variable string lengths to length n (i.e. email addresses)varchar(max) used for variable-length strings of any length up to 2G characters, basically the same as the C # String type (i.e. blog content).- preend n to these types, and your data is stored in double bytes (unicode), so your strings are more versatile in multilingual applications
SQL Server 2005 Preview
Prior to SQL Server version 2005, the [n]varchar(max) types were not supported. Instead, you had to use the [n]text types, but they were saved differently, so they were much slower compared to the [n][var]char alternatives, and they were also more cumbersome for developers to process and manipulate them.
Robert Koritnik
source share