SQL Server Substring

The substring function takes 3 arguments. The first argument is the actual string in which you want to extract from. The second argument is the start position, and the third argument is the number of characters to extract.

[cc lang=”sql”]

DECLARE @BaseString varchar(max)

SET @BaseString = ‘Quick Brown Fox’

SELECT SUBSTRING
(
@BaseString — The base string to extract from
,7 — Start Position
,5 — Length of Characters
)
[/cc]

The above query returns the value ‘Brown’.

Note: This is equivalent to the Oracle function: substr

Featured Articles

 Site Author

  • Thanks for visiting!
css.php