Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
Simple text functions
How to modify Strings


Well done! Now that we know about concatenation, let's learn some string functions. We'll start with a simple one.

The LEN() function shows the length of a string column. For example:

  LEN(FirstName) AS Length
FROM Copywriter;

Suppose that FirstName has a value of "Anne". LEN() will return a 4 because "Anne" has 4 letters. Simple, isn't it?

It's good to know that LEN() in SQL Server removes spaces from the end of a string. Look at another example:

SELECT LEN(N' Martin Bag ');

LEN() returns 11. After the trailing blanks are removed, this text consists of 11 characters (the name with a leading space: N' Martin Bag').


Show the ID number, text, and string length for every slogan in the Slogan table. Name the last column Length.

Stuck? Here's a hint!

Use LEN(Text).