Using the SUBSTRING() SQL Server Function
Using SUBSTRING() in the SELECT clause
The SUBSTRING() function is used to extract a character string from a
given starting position for a given length.
SELECT TOP 100
SUBSTRING(course_designater,6,3) as 'Course number'
FROM Courses
WHERE course_designater LIKE 'Excel%'
Format a column using SUBSTRING() and LOWER() and UPPER() functions
It is possible to use the SQL Server LOWER() and UPPER() functions in
conjunction with the SUBSTRING() function to accomplish different types
of formatting.
SELECT TOP 10
UPPER(SUBSTRING(lastname,1,1)) + LOWER(SUBSTRING(lastname,2,29)) AS 'Lastname'
FROM Students
|