Using SUBSTRING

The SUBSTRING function returns a portion of either a character or binary string, or a text string, and takes three parameters:

This example displays the first initial and last name of each employee, for example, A Fuller:

USE Northwind

SELECT SUBSTRING(FirstName, 1, 1), LastName

FROM Employees

  

This example displays the second, third, and fourth characters of the string constant abcdef:

SELECT x = SUBSTRING('abcdef', 2, 3)

  

x

----------

bcd

  

(1 row(s) affected)

  

See Also

String Functions

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.