Home > Back-end >  SQL Server DataLength issues
SQL Server DataLength issues

Time:12-08

I have a column with the following data: SMITH SMITH SMITH SMITH SMITH. When doing a SELECT DATALENGTH from the table, I am getting a value of 72.

However when I copy the column data and pop it in the select statement like the below, I get a length of 36.

SELECT DATALENGTH('JUDITH KOSGEY JUDITH JEPKORIR KOSGEY')

What could be the possible reasoning for this? I do no see any extra spaces or special characters in this text.

CodePudding user response:

If your column is NVARCHAR, it is intended to handle double byte character sets.

Use LEN() instead of DATALENGTH() and you will get the value you are expecting.

CodePudding user response:

This could be because the data column is UNICODE which takes more storage per character. What's the type of the column?

  • Related