Why is the maximum varchar length less than 8000 bytes?

So, I have a stored procedure in a SQLServer 2005 database that retrieves data from a table, formats the data as a string, and puts it in the output variable varchar (max).

However, I notice that although len (s) reports that the string should be> 8000, the actual string that I get (through the SQLServer output window) always truncates to <8,000 bytes.

Does anyone know what could be the reasons for this? Many thanks.

+3
source share
4 answers

The output window itself trims your data. The variable itself contains data, but only the first X characters are displayed in the window.

, , .NET, .

+7

SQL Server Management Studio? , ( 2008 , " | | " | SQL Server | | , | , .

+5

, .

MS Access . , Access Management Studio Query Analyzer, , .

0

However, I notice that although len (s) reports that the string should be> 8000

I also got into a problem with SQL Studio :), but not a maximum length of 8000 bytes, or 4000 for nvarchar (unicode).

Any case when the column data type is actually text or ntext , and you go to varchar ?

0
source

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


All Articles