Skip to content
 

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.


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
)

The above query returns the value ‘Brown’.

Note: This is equivalent to the Oracle function: substr



Popular search terms:

post a comment OR Post Your Question on our ASK! Community!