Replicate function in SQL Server 2008
In this article I describe replicate function in SQL Server 2008
Replicate() function is inbuilt function in SQL Server 2008 that can be used to append (replicate) characters in a particular string or values of given column. This function is mainly used in situations when user needs to make sure that all data in given column should be of fixed length. Replicate function is the best way to fix this problem.
REPLICATE (string_expression, integer expression )
string_expression- specifies character string or binary data that you want to append before the string or a number
integer_expression- It decides how many times the string_expression is to be appended.
Suppose you have table named Employee having columns (id, F_Name, L_Name, Salary, City, Region) shown in below image.
For applying replication, type following code: