Home » SQL Server » SQL Server REPLICATE Function

SQL Server REPLICATE Function

SQL Replicate Function

SQL REPLICATE() is a String function, it is used to repeat the existing string for a specified number of times.

SQL Replicate function support both character string or binary data and returns the same type as the specified expression.



Syntax:

REPLICATE(string, integer)

Description:

  • String: Specify the string to repeat
  • Integer: The number of times to repeat the string




Example:

DECLARE @String VARCHAR(100)
SET @String = 'Replicate Example - '

SELECT REPLICATE (@String, 4) AS 'Replicate Output'

Output:

SQL Replicate Function

SQL Replicate Function

As we expected, it repeated the given string four times.

Hope you enjoy the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.




Recommended SQL Server Post:

SQL Configuration Functions

IDENTITY Functions

Query Optimization Technique

SQL Commands

Leave a Reply