REPLICATE('A', 3) : REPLICATE « String Functions « SQL Server / T-SQL Tutorial






3> CREATE TABLE mytable
4> (
5>     int_val        int,
6>     smallint_val   smallint,
7>     numeric_val    numeric(8, 2),
8>     tiny_const     tinyint,
9>     float_val      float,
10>     date_val       datetime,
11>     char_strng     char(10)
12> )
13> GO
1>
2> DECLARE @myvar1 numeric(8, 2)
3> SELECT @myvar1=65.45
4>
5> INSERT mytable (int_val, smallint_val, numeric_val, tiny_const,
6>     float_val, date_val, char_strng)
7> VALUES
8> (OBJECT_ID('mytable'), @@spid, @myvar1 / 10.0, 5,
9> SQRT(144), GETDATE(), REPLICATE('A', 3) + REPLICATE('B', 3))
10> GO

(1 rows affected)
1>
2> SELECT * FROM mytable
3> GO
int_val     smallint_val numeric_val tiny_const float_val                date_val                char_strng
----------- ------------ ----------- ---------- ------------------------ ----------------------- ----------
 1019202731           51        6.55          5                       12 2008-08-17 13:19:00.380 AAABBB

(1 rows affected)
1>
2>
3> drop table myTable;
4> GO
1>
2>








12.14.REPLICATE
12.14.1.Repeating an Expression N Number of Times
12.14.2.REPLICATE is used if you wish to replicate the same string several times.
12.14.3.REPLICATE('A', 3)
12.14.4.select REPLACE(RIGHT('(559) 555-1212', 13), ') ', '-')
12.14.5.The REPLICATE() and LEN() Functions