Simple SQL-DMO Question

  • I'm trying to use SQL-DMO to determine the size of the "northwind" database:

    Dim oSQLServer

    Dim oDatabase

    Set oSQLServer = CreateObject("SQLDMO.SQLServer")

    oSQLServer.Connect "tower2", "sa"

    Set oDatabase = oSQLServer.Databases("northwind")

    Msgbox oDatabase.Size

    but .Size always returns the results in MB (not fine enough for me). For example, on my computer it returns 5 (MB) while EM show 4.25 -- the number I'm trying to get.

    Any help much appreciated.

    TIA,

    Bill Salkin

  • You can use the SizeInKB property of the Database2 object to get a more accurate measure of the DB size. The Size property of the Database object returns a long that is rounded to the MB, and won't get you enough detail.

    Hope this helps.

    Sean

  • Or you could just execute sp_spacedused, which should match what you get in EM. Not pure DMO, but easy!

    Andy

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply