Friday, March 9, 2012

How to find out how much space is being used in a file

Can anyone tell me how to find out how much space is being used in single
file on a database ?
Thank You,
-Nags
Try;
select
fileproperty ('MyFile', 'SpaceUsed')
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Nags" <nags@.DontSpamMe.com> wrote in message
news:Oo6tq7SLEHA.2068@.TK2MSFTNGP11.phx.gbl...
Can anyone tell me how to find out how much space is being used in single
file on a database ?
Thank You,
-Nags
|||how about
select [size]* 8 as [Size in KB],[name] from database..sysfiles
Don P
|||It's generally bad practice to query system tables directly, since they can
be altered at any time, e.g. service pack, hotfix, etc.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Don P" <dpfister@.noemail.noemail> wrote in message
news:uLfM0MTLEHA.3904@.TK2MSFTNGP09.phx.gbl...
how about
select [size]* 8 as [Size in KB],[name] from database..sysfiles
Don P
|||This would give the size occupied by the file on the file system, not the
space used in that file. There is a possibility that the file was
preallocated, say upto 1 Gig, but the data in the file is only 10 MB.
-Nags
"Don P" <dpfister@.noemail.noemail> wrote in message
news:uLfM0MTLEHA.3904@.TK2MSFTNGP09.phx.gbl...
> how about
> select [size]* 8 as [Size in KB],[name] from database..sysfiles
> Don P
>

No comments:

Post a Comment