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
If you find this site useful and are a book buyer/reader...
You can support my site by clicking on one of the Links below to Abe books
By doing this, I will receive a small commision on your purchase and making your purchase
will not cost you any more money than if you went directly the site yourself!
Abe Books sells books at a fraction of the original cost. I
have purchased many books from them originally cost $40.00 for as little as $5 to $10 dollars
including shipping costs
Click on applicable icon to find books at Abe Books on ...
|
| SQL Server 2008 |
SQL Server 2005 |
SQL Server 2000 |
T-SQL |
|
|
|
|
|
|
Abe Books is one of my affiliates. I only use affiliates that I also
purchase products from. I love Abe books. If it is printed they likely
have a copy. I have also included a generic link to Abe Books below.
Once on their site, you will find that they have a nice, easy to use search engine so
to find what you are looking for. |

|