I added a table to a database with the following column names and datatypes
“ID” bigInt, “Description” nchar(11)
If I check the design view of the table, the datatypes of the columns are as I set them.
If I write a query that will get the columns in that table from SYS.COLUMNS the column properties are different e.g.(the max_length of description is 22, not 11)
Can someone explain why that is?
I am using Microsoft SQL Server Enterprise Edition (64-bit) if that is relevant.
The column
max_lengthin sys.columns show the max length in bytes. nchar is double byte so 11 chars take 22 bytes.If you want the number of characters you could use INFORMATION_SCHEMA.COLUMNS
Or you could use the function COLUMNPROPERTY