The RPAD function

Use the RPAD function to return a copy of a string that has been right 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 RPAD 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 RPAD function pads the first six positions to the right of the source string.
Figure 1: Query
SELECT sname, RPAD(sname, 21, "-")
   FROM state
   WHERE code = "WV" OR code = "AZ";
Figure 2: Query result
sname           (expression)   
West Virginia   West Virginia  ------
Arizona         Arizona        ------

In addition to these functions, the LTRIM and RTRIM functions can return a value that drops specified leading or trailing padding characters from their string argument, and the ASCII function can return the numeric value of the codepoint within the ASCII character set of the first character in its string argument. These built-in functions for operations on string values are described in theHCL OneDB™ Guide to SQL: Syntax.