SQL Server Performance

Varchar(max) datatype and Replicate function

Discussion in 'Other SQL Server Blogs around the Web' started by Anonymous, Jul 15, 2008.

  1. Anonymous New Member

    As you know, Replicate function is used to repeat a character expression for a specified number of times. But by default the result is converted to varchar of maximum size 8000 when you dont convert the expression to specific type Consider the following example declare @v varchar ( max ) set @v = replicate ( 'a' , 50000 ) select len ( @v ), datalength ( @v ) Note that the result is not 50000 but 8000 because by default the result is limited to the maximum size of 8000 for varchar/char datatype To...(<a href="http://sqlserver-qa.net/blogs/t-sql/archive/2008/07/15/4612.aspx">read more</a>)<img src="http://sqlserver-qa.net/aggbug.aspx?PostID=4612" width="1" height="1">

Share This Page