I am trying to determine the size in bytes of the contents in a VARBINARY(MAX)
field in SQL Server 2005, using SQL. As I doubt there is native support for this, could it be done using CLR integration? Any ideas would be greatly appreciated.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Actually, you can do this in T-SQL!
DATALENGTH(<fieldname>)
will work on varbinary(max)
fields.
回答2:
The VARBINARY(MAX) field allocates variable length data up to just under 2GB in size.
You can use DATALENGTH() function to determine the length of the column content.
For example:
SELECT DATALENGTH(CompanyName), CompanyName
FROM Customers