SQL Server Substring
-
Posted on April 11, 2010 by Derek Dieter
-
1
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
Post a comment
- Comments (RSS)
- Trackback
- Permalink