Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2002
    Posts
    229

    Unanswered: Checking database size from T-SQL

    Which is the best way to check the size of a database from Transact SQL ? (Selecting from Sysfiles gives a totally different result compared to right-clicking a database and selecting Properties. It's the result from the latter than I want to obtain through Transact sQL.)

  2. #2
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    exec sp_spaceused

  3. #3
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    might want to throw in the updateusage parameter.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  4. #4
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    btw, if you ever want to know exactly what EM or SSMS is doing to get the results it's showing you, just turn on the profiler and start clicking around in EM/SSMS.

    EDIT: Really, this will tell you what DMO/SMO is doing, since EM and SSMS use DMO and SMO under the covers.

  5. #5
    Join Date
    Mar 2005
    Location
    Netherlands
    Posts
    280
    Quote Originally Posted by jezemine
    just turn on the profiler and start clicking around in EM/SSMS.
    And I alway get very sad when I see just how much traffic just one click in EM generates...

  6. #6
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    you think that's bad, try SSMS. SMO is a very chatty api.

  7. #7
    Join Date
    Mar 2005
    Location
    Netherlands
    Posts
    280
    Quote Originally Posted by jezemine
    you think that's bad, try SSMS. SMO is a very chatty api.
    I'm not sure I want to know The only thing that can make it a little more easier to live with if the uncatchable "refresh"-problem in EM is history in SSMS:

    Me: I just created the table you wanted
    Developer: <click><click> I don't see it
    Me: Did you refresh the table list? You were probably already connected before I created it.
    Developer: <click><click><click> I did, but I still don't see it
    Me: Did you do a refresh on the instance or on the table list, you must refresh the table list separately
    Developer: <click><click><click> Did that but I still don't see it
    Me: <sigh> just disconnect and reconnect...
    Developer: <click><click><click> Ah, there it is!

  8. #8
    Join Date
    Jul 2002
    Posts
    229
    I was just about to try tracking what, in my case,
    Mgmt Studio Express, is doing, but sp_spaceused
    did the trick!
    Thank you!

  9. #9
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    fyi, you can also pass a table name to sp_spaceused to get the size of data/indexes in it.

Posting Permissions

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