Beginner

237. REPEAT Function

Learn how to repeat a text value multiple times.

📘 Lesson 237 of 728 ⏱ 8 min 🎯 Intermediate

The REPEAT function returns a string created by repeating another string a specified number of times in database systems that support the function.

Repeated text can be useful when generating formatted output or creating controlled text patterns.

Generate a repeated separator for formatted output.

SQL
SELECT
    REPEAT('-', 10) AS Separator;

REPEAT can be used for formatting, testing, text generation, and specialized reporting requirements.

  • REPEAT duplicates a string multiple times.
  • A repetition count is specified.
  • It is mainly useful for formatting or text generation.
  • Database support varies.
  • It can be combined with other string functions.
What does REPEAT do?

REPEAT creates a string by repeating another string a specified number of times.

Where can REPEAT be useful?

It can be useful for formatted output, testing, and specialized text-generation tasks.

Have you finished this lesson?

Introduction to SQL – All Lessons