Results 1 to 4 of 4

Thread: MS-SQL(MSDE) How can i see with a select the available database space

  1. #1
    Join Date
    Jan 2005
    Location
    Rio de Janeiro, Brazil
    Posts
    4

    Question MS-SQL(MSDE) How can i see with a select the available database space

    Is it possible to select the available space of the database in a microsoft sql MSDE edition?

    With sysfiles i can see the size of the database but where can i find the available space or the used space of the database.

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    --For datafile
    declare @query varchar(200)
    set @query ='DBCC showfilestats'
    create table #mytable(Fileid int, FileGroup int, Totalextents bigint,UsedExtents bigint,Name varchar(256),Filename varchar(600))
    insert #mytable exec (@query)
    select Name,Filename,(TotalExtents*64)/1024 as TotalMB,(Usedextents*64)/1024 as UsedMB,
    Free= ((TotalExtents*64) - (Usedextents*64))/1024,
    FreePercent=(((TotalExtents*64*1.0) - (Usedextents*64*1.0))/(TotalExtents*64*1.0))*100
    from #mytable
    drop table #mytable

    --For Logfile

    dbcc sqlperf(logspace)

  3. #3
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can run sp_spaceused to get an estimate. But run dbcc updateusage to get upto date data.

  4. #4
    Join Date
    Jan 2005
    Location
    Rio de Janeiro, Brazil
    Posts
    4

    Thumbs up

    Thanks it works perfectly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •