T-SQL 101: 49 Using REPLICATE to repeat strings in SQL Server
REPLICATE is an easy function to work with. It takes a string and a number of times you want it repeated. Here’s an example:


In this case, I’ve asked it to replicate (i.e. duplicate many times) an A character. I’ve asked for 5 of them. I put an X at each end so you could see the effect more clearly.
There are many things this can be used for, but for example, if I wanted to draw a line with 100 dashes, I could just ask for REPLICATE(’-’, 100).
2019-12-23

