SQL Server/T-SQL Tutorial/String Functions/LEN

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

Determining the Number of Characters or Bytes in a String by using LEN

   <source lang="sql">

3> 4> SELECT LEN(N"www.sqle.ru. sqle") 5> GO


        22

(1 rows affected)</source>


LEN Returns the length of a string as an integer.

   <source lang="sql">

3> 4> DECLARE @LEN_STRING varchar(100) 5> SET @LEN_STRING = "www.sqle.ru" 6> 7> SELECT LEN(@LEN_STRING) 8> GO


        14

(1 rows affected)</source>


select LEN("SQL Server")

   <source lang="sql">

2> 3> select LEN("SQL Server") 4> GO


        10

(1 rows affected) 1></source>


select LEN(" SQL Server ") (space at both ends)

   <source lang="sql">

3> select LEN(" SQL Server ") 4> GO


        11

(1 rows affected)</source>