Why listing text like varchar truncates text with 30 characters without specifying the length?

I searched the MS-SQL Server 2005 database to make sure that the specific text field is always a multiple of 8. When I ran the following query, I realized that several lines are 30 in length. But when I examined these records, I found that they were longer.

select distinct len(cast(textfield as varchar)) from tablename

However, if I specify the varchar length as something longer (as in the following query), it works fine.

select distinct len(cast(textfield as varchar(1000))) from tablename

Does anyone know why it defaults to 30, and if it's a custom parameter?

+3
source share
3 answers

, , . , , , , , , - 30, , .

, , - 256 VARCHAR, , , , , .

+1

This is an arbitrary number, and as far as I know, it is not configurable. I can not think of a case where you do not want to indicate the length.

0
source

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


All Articles