SQL Server String Functions-3

A string function accepts a string value as an input and returns a string value regardless of the data type. They’re used to convert an existing string value to a different format, change the letter cases, retrieve a portion of it, or determine the length of it. They are utilized in reports, logic implementation, and data analysis on a daily basis.

This will be a series of postings since we will go over each one in detail with one or more examples for simple comprehension. So continue reading.

For previous article, click here.

LEN:
Returns the number of characters of the specified string expression, excluding trailing spaces.

  Syntax:
LEN ( string_expression)

Example:

SELECT e.Ename, LEN(e.Ename), d.DName, LEN(d.Dname)
FROM Emp e
INNER JOIN Dept d ON e.deptNo = d.DeptNo
WHERE e.DeptNo = 10
GO

LOWER:
Returns a character expression after converting uppercase character data to lowercase.

  Syntax:
LOWER( string_expression)

Example:

SELECT e.Ename, LOWER(e.Ename), d.DName, LOWER(d.Dname)
FROM Emp e
INNER JOIN Dept d ON e.deptNo = d.DeptNo
WHERE e.DeptNo = 10
GO

LTRIM:
Returns a character expression after converting uppercase character data to lowercase.

  Syntax:
LTRIM( string_expression)

Example:

SELECT e.Ename, LTRIM(e.Ename), d.DName, LTRIM(d.Dname)
FROM Emp e
INNER JOIN Dept d ON e.deptNo = d.DeptNo
WHERE e.DeptNo = 10
GO

Lower_LTRIM_functions_SQLServer

Please continue to read the articles on String functions that will be published in the near future.

3 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s