The Length function in SQL is used to get the length of a string. The syntax is:

LEN(string)

Let’s take a look at some examples. Assume we have the following table:

Store Regions

Region StoreName
East Boston
East New York
West LA
West San Diego

Example 1:
SELECT Length(storename)
FROM Geography
WHERE storename = ‘Los Angeles’;
Result:
11

Example 2:
SELECT region_name, Length(region)
FROM Geography;
Result:
region
Length(region)
East
4
East
4
West
4
West
4

Bookmark it and Share
  • Digg
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Netvouz
  • De.lirio.us
  • Furl
  • NewsVine
  • Reddit
  • YahooMyWeb