Size of VARBINARY field in SQL Server 2005

大兔子大兔子 提交于 2019-11-26 19:58:39

问题


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


来源:https://stackoverflow.com/questions/507785/size-of-varbinary-field-in-sql-server-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!