SQL Server/T-SQL/String Functions/DATALENGTH

Материал из SQL эксперт
Перейти к: навигация, поиск

DATALENGTH() for for Unicode character set

1>
2> -- DATALENGTH(): .
4>
5>
6> DECLARE @Value1 Int, @Value2 Int
7> SET @Value1 = 2
8> SET @Value2 = 2000000000
9>
10> SELECT DATALENGTH(@Value1), LEN(@Value1), DATALENGTH(@Value2), LEN(@Value2)
11> GO
----------- ----------- ----------- -----------
          4           1           4          10
(1 rows affected)
1>
2>



DATALENGTH(): returns the number of bytes used to manage a value

1> -- DATALENGTH(): returns the number of bytes used to manage a value.
2>
3> DECLARE @Value VarChar(20)
4> SET @Value = "abc"
5>
6> SELECT LEN(@Value)
7> GO
-----------
          3
(1 rows affected)
1>



DATALENGTH(@Value)

1> DECLARE @Value nVarChar(20)
2> SET @Value = "abc"
3>
4> SELECT DATALENGTH(@Value)
5> GO
-----------
          6
(1 rows affected)
1>