Saturday, August 15, 2020

REPLICATE() Function in SQL Server

SQL Server REPLICATE() function is used to repeat a specified string for a given number of time.

Syntax:
REPLICATE (string, integer)

Example:

1. 
Select replicate('A',5)

Output:
AAAAA

2.
Select replicate(('A'+' '),5)

Output:
A A A A A 

3.

select Name,REPLICATE('0',3)+ProductLine as Prod_Code from Production.Product
where ProductLine='R'



No comments:

Post a Comment