SQL SUBSTRING

Transact-SQL (TSQL) Quick Tips – SQL SUBSTRING Function

Here is a simple example of how the SQL SUBSTRING function works.  You can copy this code into your Query Window and EXECUTE as-is.  The code includes a #temp table with data to illustrate the functionality.  You can modify to suit your needs.

The SQL SUBSTRING function returns part of a character, binary, text, or image expression in SQL Server.

SYNTAX:  SUBSTRING ( expression, start, length )

Query Results:

SQL SUBSTRING

Below is a more complex example, using the SQL SUBSTRING Function in tandem with the SQL CHARINDEX Function.

( Check out my post on SQL CHARINDEX Here )

This allows you to dynamically locate the starting character location for position (QB, RB, WR)

Query Results:

SQL SUBSTRING

Additional Content

Check out more examples by visiting my Home Page

Here you will find topics covering  Qlikview  SQL Server  Excel VBA

 

Leave a Comment