How to get the size of a file uploaded to SQL-Server?

Is there any way to find out how to get the size of the file that is uploaded to the database?

SELECT [ID]
      ,[File]
  FROM [dbo].[Reports]

I would like to tell the user the size of the file that is in the field VarBinary(max)in MS SQL 2005/2008. How to do it?

Maybe the only way to do this is to create another column, and when I insert a file, I also have to insert it into an additional column?

+3
source share
2 answers

You can use the function datalength:

select ID, File, Length = datalength(File)
from dbo.Reports
+4
source

Use DATALENGTH () to retrieve the VARBINARY size

+1
source

Source: https://habr.com/ru/post/1736875/


All Articles