Other related articles:

Recently viewed articles:

SQL LPAD Function

SQL LPAD also called left pad is used to add characters or spaces to the left of a string. The syntax is

LPAD (CHARACTER SET)

Example 1:

The following SQL LPAD function pad spaces to the left of each name, totaling 30 characters for each name regardless of length of name.

SELECT LPAD (first_name, 30) name FROM employee;

Output:

sql-lpad-image1

Example 2:
The following SQL LPAD function is same as above except that it adds periods instead of spaces.

SELECT LPAD (name, 30,'.') name FROM employee;

Output:

sql-lpad-image2