What is the size of a image field content in SQL Server?

我们两清 提交于 2019-12-06 16:29:53

问题


I have a table in SQL Server. This table has an image field and the application stores files in it.

Is there a way to read the size of the file in the image field using T-SQL?


回答1:


SELECT DATALENGTH(imagecol) FROM  table

See MSDN




回答2:


Different display styles:

SELECT DATALENGTH(imagecol) as imgBytes,
       DATALENGTH(imagecol) / 1024 as imgKbRounded,
       DATALENGTH(imagecol) / 1024.0 as imgKb,      
       DATALENGTH(imagecol) / 1024 / 1024 as imgMbRounded,
       DATALENGTH(imagecol) / 1024.0 / 1024.0 as imgMb
FROM   table

Example output:

imgBytes    imgKbRounded    imgKb       imgMbRounded    imgMb
68514       66              66.908203   0               0.065340041992


来源:https://stackoverflow.com/questions/10019438/what-is-the-size-of-a-image-field-content-in-sql-server

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