In SQL Server, the @@TEXTSIZE
configuration function returns the current value of the TEXTSIZE
option.
No argument is required. You can simply use it in a SELECT
statement to return the current TEXTSIZE
value.
The TEXTSIZE
value specifies the size of varchar(max), nvarchar(max), varbinary(max), text, ntext, and image data returned by a SELECT
statement. This value can be set using SET TEXTSIZE
.
Example 1 – Default Value in Azure Data Studio
Here’s what I get in Azure Data Studio.
SELECT @@TEXTSIZE AS [Text Size];
Result:
+-------------+ | Text Size | |-------------| | 2147483647 | +-------------+
This is the default value that Azure Data Studio uses when I connect. It’s also the maximum value that TEXTSIZE
can be set to.
However, the SQL Server Native Client (10.0 and higher) and ODBC Driver for SQL Server automatically specify -1 when connecting. This value means unlimited. Drivers older than SQL Server 2008 specify 2147483647 (2 GB).
Example 2 – Default Value in mssql-cli
Here’s what I get in the mssql-cli command line tool.
SELECT @@TEXTSIZE AS [Text Size];
Result:
+-------------+ | Text Size | |-------------| | -1 | +-------------+
As mentioned, this means the TEXTSIZE
is unlimited.
The values returned here are simply the default values that my software uses when they connect to SQL Server. You can change the TEXTSIZE
value at any time with the SET TEXTSIZE
statement.