You see things; and you say 'Why?' But I dream things that never were; and I say 'Why not?'

Monday, February 9, 2009

How to get length of data in Text, NText and Image columns in SQL Server

There is sometimes a need to figure out the maximum space that is being used by a particular column in your database. You would initially think that the LEN() function would allow you to do this, but this function does not work on Text, NText or Image data types, so how do you figure out the length of a value in a column that has one of these data types?

SELECT name, DATALENGTH(packagedata) FROM dbo.sysdtspackages

No comments:

Followers