Skip to main content
Previous sectionNext section

REPEAT

A string function that repeats a string a specified number of times.

Synopsis

REPEAT(expression,repeat-count)
{fn REPEAT(expression,repeat-count)}

Arguments

Argument Description
expression The string expression to be repeated.
repeat-count The number of times to repeat, expressed as an integer.

Description

REPEAT returns a string of repeat-count instances of expression, concatenated together.

If expression is NULL, REPEAT returns NULL. If expression is the empty string, REPEAT returns an empty string.

If repeat-count is a fractional number, only the integer part is used. If repeat-count is 0, REPEAT returns an empty string. If repeat-count is a negative number, NULL, or a non-numeric string, REPEAT returns NULL.

Examples

The following examples show the two forms of REPEAT. Both examples return the string 'BANGBANGBANG':

SELECT REPEAT('BANG',3) AS Tripled
Copy code to clipboard
SELECT {fn REPEAT('BANG',3)} AS Tripled
Copy code to clipboard

See Also