I have a table in SQL Server. This table has an image field and the application stores files in it.
我在SQL Server中有一个表。该表有一个图像字段,应用程序在其中存储文件。
Is there a way to read the size of the file in the image field using T-SQL?
是否有一种方法可以使用T-SQL读取图像字段中的文件大小?
2 个解决方案
#2
3
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
#1
#2
3
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