SQL Server中图像字段内容的大小是多少?

时间:2020-12-02 16:08:05

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 个解决方案

#1


65  

SELECT DATALENGTH(imagecol) FROM  table

See MSDN

看到MSDN

#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


65  

SELECT DATALENGTH(imagecol) FROM  table

See MSDN

看到MSDN

#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