Getting Character Count in MS SQL

In Ms Sql, LEN() function is used to get the number of characters of a string type data (char, varchar..).

The name of the LEN() function comes from "length".

The LEN function includes leading spaces in the string, but not trailing spaces.

Let's examine the examples below...

SELECT LEN('develop')

The result returns 7..

SELECT LEN(' develop')

The result returns 8..

SELECT LEN('develop ')

The result returns 7..

SELECT LEN(' develop ')

The result returns 8..


You May Interest

Getting the Id of MS SQL Server Last Entered Record

Making a Backup of MS SQL Database With Query

Finding Server Default Language in MS SQL

What is the Difference Between VARCHAR and VARCHAR(MAX) Datatypes ...

What is the Bookmark Lookup and RID Lookup in SQL Server ?