---
title: "Write a SQL command to repeat a string a specified number of time?"  
description: "Write a SQL command to repeat a string a specified number of time?"  
author: "Ashutosh Kumar Verma"  
published: 2021-11-15  
canonical: https://www.mindstick.com/interview/33821/write-a-sql-command-to-repeat-a-string-a-specified-number-of-time  
category: "mssql server"  
tags: ["sql server", "sql"]  
reading_time: 1 minute  

---

# Write a SQL command to repeat a string a specified number of time?

The **REPLICATE()** function is used to print a string to specified number of time in SQL Server.

Syntax- REPLICATE(string, integer);

Example:

```
SELECT REPLICATE('MindStick.com ', 3);
```

**Output:**

MindStick.com MindStick.com MindStick.com **\** Also used to print any number in repeated number of given time.

```
SELECT REPLICATE(1456398784 , 3);
```

145639878414563987841456398784

## Answers

### Answer by Ashutosh Kumar Verma

The **REPLICATE()** function is used to print a string to specified number of time in SQL Server.

Syntax- REPLICATE(string, integer);

Example:

```
SELECT REPLICATE('MindStick.com ', 3);
```

**Output:**

MindStick.com MindStick.com MindStick.com **\** Also used to print any number in repeated number of given time.

```
SELECT REPLICATE(1456398784 , 3);
```

145639878414563987841456398784


---

Original Source: https://www.mindstick.com/interview/33821/write-a-sql-command-to-repeat-a-string-a-specified-number-of-time

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
