SPACE (SQL)
Synopsis
SPACE(count)
{fn SPACE(count)}
Description
SPACE returns a string of blank spaces count spaces long. If count is a numeric string, a decimal number, or a mixed numeric string, InterSystems IRIS resolves it to its integer portion. If count is a negative number or a nonnumeric string, InterSystems IRIS resolves it to 0.
To remove blank spaces from a string, use LTRIM (leading blanks) or RTRIM (trailing blanks).
The SPACE function should not be confused with the SPACE collation type. SPACE collation prepends a single space to a value, forcing it to be evaluated as a string. To establish SPACE collation, CREATE TABLE provides a %SPACE collation keyword, and ObjectScript provides the Collation()Opens in a new tab method of the %SYSTEM.UtilOpens in a new tab class.
Arguments
count
An integer expression specifying the number of blank spaces to return.
Examples
The following example returns a string of spaces the length of the name field:
SELECT SPACE(LENGTH(name))
FROM Sample.Person