Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Varchar(max) datatype and Replicate function

Jul 15 2008 2:07PM by Madhivanan   

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 get a correct result, you need to convert the expression to the type of varchar(max)

declare @v varchar(max)
set @v=replicate(convert(varchar(max),'a'),50000)
select len(@v),datalength(@v)

Now the result is 50000 as expected. So you need to be aware of this implicit convertion when using Replicate function to assingn value to the column of varchar(max) datatype

Tags: t-sql, sql_server, replicate,


Madhivanan
3 · 40% · 12958
1
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Varchar(max) datatype and Replicate function" rated 5 out of 5 by 1 readers
Varchar(max) datatype and Replicate function , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]