Friday, November 28, 2008

[T-SQL] How to get length of TEXT field

To calculate the lenght of a TEXT field the LEN function used to calculate the length of VARCHAR fields won't work. 

You need to use the DATALENGTH T-SQL function:

SELECT DATALENGTH(myTextField) AS lengthOfMyTextField



kick it on DotNetKicks.com

2 comments:

Anonymous said...

Hi,

Thanks pretty useful i'll kickit.

You can take a look at my technical blog so

Scott Harner said...

Thanks for the tip. It proved useful in doing a quick check of field lengths.