SQL Server Information and Resources Bookmark this page

SQLINFO.net is a Community Service from DataExpressions makers of dbOrchestra©

Google
 

 

 

 


SQL Server Examples

SQL DML

String Functions

Stored Procedures

SQL Views

SQL Table Basics


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

 



Copyright 2006-2007 by DataExpressions --- All Rights Reserved            dbOrchestra - SQL Server home page