开发者

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

开发者 https://www.devze.com 2022-12-23 01:17 出处:网络
Is there a way to tell how to get a file size that is uploaded to database? SELECT [ID] ,[File] FROM [dbo].[Reports]

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 开发者_JAVA百科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?


You can use the datalength function:

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号