views:

26

answers:

2

Is there a way to tell how to get a file size that is uploaded to database?

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

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

Maybe the only way to do is to create another column and when inserting file i should also insert it's size in additional column?

+1  A: 

Use the DATALENGTH() function to retrieve the size of a VARBINARY

devio
+1  A: 

You can use the datalength function:

select ID, File, Length = datalength(File)
from dbo.Reports
Guffa
Thanks. Exactly what i needed.
MadBoy