SELECT DATALENGTH(@Value2) : DATALENGTH « System Functions « SQL Server / T-SQL Tutorial






5> DECLARE @Value1 Int, @Value2 Int
6> SET @Value1 = 2
7> SET @Value2 = 2000000000
8> SELECT DATALENGTH(@Value1)
9> SELECT LEN(@Value1)
10> SELECT DATALENGTH(@Value2)
11> SELECT LEN(@Value2)
12> GO

-----------
          4

(1 rows affected)

-----------
          1

(1 rows affected)

-----------
          4

(1 rows affected)

-----------
         10

(1 rows affected)








25.7.DATALENGTH
25.7.1.Using DATALENGTH to determine length of a string value.
25.7.2.The DATALENGTH() function returns the number of bytes used to manage a value.
25.7.3.SELECT DATALENGTH(@Value2)
25.7.4.DATALENGTH Versus COL_LENGTH to determine length of a string value.