Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 file size through sql

Author  Topic 

dev45
Yak Posting Veteran

54 Posts

Posted - 2005-03-23 : 04:46:30
hello,
i have stored pdf files in an image column (for the time being,the column might store any kind of files). Is there a way to determine the size of them (if the files resided on the file system) by using sql or do i have to recreate each one ,save it on disk , use file I/O (from vb.net) to calculate their size and store in in another column ? (obviously the demand to store the file size came long after the files where saved to sql server)
thx a lot
theodore

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2005-03-23 : 04:58:25
Hi Theodore,
You'll find many convincing arguments on this site against storing files in SQL server! However, the DATALENGTH function will return "the number of bytes used to represent any expression".


Mark
Go to Top of Page

dev45
Yak Posting Veteran

54 Posts

Posted - 2005-03-23 : 04:58:47
ok, think i found it
select fileNameColumn, datalength(fileColumn) as fileSize from tblName
if i am wrong let me know ;-)
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2005-03-23 : 05:38:15
Bear in mind that the file size (within sql) may not match the file size (on any particular disk).

You'd be better off shifting your files out of the database.

-------
Moo. :)
Go to Top of Page
   

- Advertisement -