REPLICATE (TSQL Function)

Returns the a string, replicated the specified number of times.

Syntax

REPLICATE ( string_expression , integer_expression )

Arguments

string_expression
string to replicate. It is of type varchar.
integer_expression
number of times to replicate string_expression. It is of type int.

Return Types

Returns varchar.

Remarks

If integer_expression < 0, NULL is returned.

Examples

PRINT REPLICATE('Hello', 3);
PRINT REPLICATE('Hello', 2);
PRINT REPLICATE('Hello', 1);
PRINT REPLICATE('Hello', 0);
PRINT REPLICATE('Hello', -3);

The result is:

HelloHelloHello
HelloHello
Hello

<NULL>