The LPAD function
Use the LPAD function to return a copy of a string that has been left padded with a sequence of characters that are repeated as many times as necessary or truncated, depending on the specified length of the padded portion of the string. Specify the source string, the length of the string to be returned, and the character string to serve as padding.
The data type of the source string and the character string that serves as padding can be any data type that converts to VARCHAR or NVARCHAR.
The following query shows an
example of the LPAD function with a specified length of 21 characters. Because
the source string has a length of 15 characters (sname is defined as CHAR(15)), the
LPAD function pads the first six positions to the left of the source string.