Подія
31 бер., 23 - 2 квіт., 23
Найбільший навчальний захід SQL, Fabric і Power BI. 31 березня – 2 квітня. Щоб заощадити 400 грн, скористайтеся кодом FABINSIDER.
Реєструйтеся сьогодніЦей браузер більше не підтримується.
Замініть його на Microsoft Edge, щоб користуватися перевагами найновіших функцій, оновлень безпеки та технічної підтримки.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
This function returns the number of bytes used to represent any expression.
Примітка
To return the number of characters in a string expression, use the LEN function.
Transact-SQL syntax conventions
DATALENGTH ( expression )
expression
An expression of any data type.
bigint if expression has an nvarchar(max), varbinary(max), or varchar(max) data type; otherwise int.
DATALENGTH
becomes really helpful when used with data types that can store variable-length data, such as:
For a NULL value, DATALENGTH
returns NULL.
Примітка
Compatibility levels can affect return values. See ALTER DATABASE Compatibility Level (Transact-SQL) for more information about compatibility levels.
Примітка
Use the LEN to return the number of characters encoded into a given string expression, and DATALENGTH to return the size in bytes for a given string expression. These outputs may differ depending on the data type and type of encoding used in the column. For more information on storage differences between different encoding types, see Collation and Unicode Support.
This example finds the length of the Name
column in the Product
table:
USE AdventureWorks2022
GO
SELECT length = DATALENGTH(EnglishProductName), EnglishProductName
FROM dbo.DimProduct
ORDER BY EnglishProductName;
GO
LEN (Transact-SQL)
CAST and CONVERT (Transact-SQL)
Data Types (Transact-SQL)
System Functions (Transact-SQL)
Подія
31 бер., 23 - 2 квіт., 23
Найбільший навчальний захід SQL, Fabric і Power BI. 31 березня – 2 квітня. Щоб заощадити 400 грн, скористайтеся кодом FABINSIDER.
Реєструйтеся сьогодні