Tuesday, 16 July 2013

Extract Characters using Substring in SQL

Substring in SQL will Extract the characters from an starting point of the strings in the column name of the database.The syntax for it is

SUBSTRING(string or column name, startIndex, length)
string denotes the columnname or the string value
start index denotes the starting point from where extraction begins
length denotes the how many characters to be extracted.

Example Select query using substring:
SELECT SUBSTRING(Names,2,3) as 'substring' FROM TABLENAME
This query will return Names starting from 3 and return 3 characters from the strings in that columname. 

No comments:

Post a Comment

back to top