SQL Server/T-SQL/String Functions/Substring

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

Substring: get the substring

   <source lang="sql">

1> DECLARE @FullName VarChar(25) 2> SET @FullName = "www.sqle.ru" 3> SELECT SUBSTRING(@FullName, CHARINDEX(".", @FullName) + 1, LEN(@FullName)) 4> GO


sqle.ru (1 rows affected) 1> 2>

      </source>
   
  


SUBSTRING(): starts at a position and counts characters to the right, returning a substring of a specified length

   <source lang="sql">

1> -- SUBSTRING(): starts at a position and counts characters to the right, returning a substring of a specified length. 2> 3> DECLARE @FullName VarChar(25) 4> SET @FullName = "www.sqle.ru" 5> SELECT SUBSTRING(@FullName, 4, 6) 6> GO


.java2 (1 rows affected) 1> 2>

      </source>
   
  


SUBSTRING(string_to_remove_string_from, start_position, length)

   <source lang="sql">

1> -- SUBSTRING(string_to_remove_string_from, start_position, length) 2> SELECT SUBSTRING("www.sqle.ru www.sqle.ru",20,7) 3> GO


sqle. (1 rows affected) 1>

      </source>