query/read database size?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob Wahmann

    query/read database size?

    I have a web-based admin section for a site and I would like to be able to
    query the SQL Server database size and display it within my admin area. Is
    there a function or method of doing this? My database is hosted by a third
    party...

    I appreciate any tips or advice you can provide!

    Rob


  • Simon Hayes

    #2
    Re: query/read database size?

    "Rob Wahmann" <dotcomstudio@s bcglobal.net> wrote in message
    news:bWdVa.2753 7$BM.8963811@ne wssrv26.news.pr odigy.com...[color=blue]
    > I have a web-based admin section for a site and I would like to be able to
    > query the SQL Server database size and display it within my admin area. Is
    > there a function or method of doing this? My database is hosted by a third
    > party...
    >
    > I appreciate any tips or advice you can provide!
    >
    > Rob
    >[/color]

    Depending on what information you need, sp_helpdb might be good enough:

    exec sp_helpdb MyDB

    Simon


    Comment

    • Rob Wahmann

      #3
      Re: query/read database size?

      Re: exec sp_helpdb MyDB

      Thanks, Simon. I've seen a lot of those commands thrown around but how do I
      actually run that? I'm pretty new to SQL Server and I've never set up a
      stored procedure or a trigger... I'm doing everything right now with queries
      and an ODBC connection. These sites are relatively small but I do need to
      learn this stuff so I can build more robust apps.

      Thanks!

      Rob

      "Simon Hayes" <sql@hayes.ch > wrote in message
      news:3f256df9$1 _2@news.bluewin .ch...[color=blue]
      > "Rob Wahmann" <dotcomstudio@s bcglobal.net> wrote in message
      > news:bWdVa.2753 7$BM.8963811@ne wssrv26.news.pr odigy.com...[color=green]
      > > I have a web-based admin section for a site and I would like to be able[/color][/color]
      to[color=blue][color=green]
      > > query the SQL Server database size and display it within my admin area.[/color][/color]
      Is[color=blue][color=green]
      > > there a function or method of doing this? My database is hosted by a[/color][/color]
      third[color=blue][color=green]
      > > party...
      > >
      > > I appreciate any tips or advice you can provide!
      > >
      > > Rob
      > >[/color]
      >
      > Depending on what information you need, sp_helpdb might be good enough:
      >
      > exec sp_helpdb MyDB
      >
      > Simon
      >
      >[/color]


      Comment

      • Simon Hayes

        #4
        Re: query/read database size?

        "Rob Wahmann" <dotcomstudio@s bcglobal.net> wrote in message
        news:ebeVa.2755 0$BM.8967078@ne wssrv26.news.pr odigy.com...[color=blue]
        > Re: exec sp_helpdb MyDB
        >
        > Thanks, Simon. I've seen a lot of those commands thrown around but how do[/color]
        I[color=blue]
        > actually run that? I'm pretty new to SQL Server and I've never set up a
        > stored procedure or a trigger... I'm doing everything right now with[/color]
        queries[color=blue]
        > and an ODBC connection. These sites are relatively small but I do need to
        > learn this stuff so I can build more robust apps.
        >
        > Thanks!
        >
        > Rob
        >[/color]

        <snip>

        Any procedure beginning with sp_ is a system stored procedure - most are in
        the master database (some are in msdb) but you can execute the ones in
        master from any database on the server. I don't know much about ODBC, but if
        you're already passing queries to the server and getting results, then try
        to just pass the query text "exec sp_helpdb MyDB" (without the quotes, of
        course), and handle the results like any other query.

        One thing to be aware of is that stored procedures may return multiple
        result sets, so you have to parse each result set to get all the
        information. sp_helpdb returns two result sets. Books Online is an excellent
        reference for all the system stored procedures - they are all listed under
        the "System Stored Procedures" topic (at least assuming you have SQL2000 -
        you didn't mention your version).

        Simon


        Comment

        • Rob Wahmann

          #5
          Re: query/read database size?

          Thanks again! I'm going to toy around with how to call the stored proc.

          Regards,

          Rob

          "Simon Hayes" <sql@hayes.ch > wrote in message
          news:3f257215_4 @news.bluewin.c h...[color=blue]
          > "Rob Wahmann" <dotcomstudio@s bcglobal.net> wrote in message
          > news:ebeVa.2755 0$BM.8967078@ne wssrv26.news.pr odigy.com...[color=green]
          > > Re: exec sp_helpdb MyDB
          > >
          > > Thanks, Simon. I've seen a lot of those commands thrown around but how[/color][/color]
          do[color=blue]
          > I[color=green]
          > > actually run that? I'm pretty new to SQL Server and I've never set up a
          > > stored procedure or a trigger... I'm doing everything right now with[/color]
          > queries[color=green]
          > > and an ODBC connection. These sites are relatively small but I do need[/color][/color]
          to[color=blue][color=green]
          > > learn this stuff so I can build more robust apps.
          > >
          > > Thanks!
          > >
          > > Rob
          > >[/color]
          >
          > <snip>
          >
          > Any procedure beginning with sp_ is a system stored procedure - most are[/color]
          in[color=blue]
          > the master database (some are in msdb) but you can execute the ones in
          > master from any database on the server. I don't know much about ODBC, but[/color]
          if[color=blue]
          > you're already passing queries to the server and getting results, then try
          > to just pass the query text "exec sp_helpdb MyDB" (without the quotes, of
          > course), and handle the results like any other query.
          >
          > One thing to be aware of is that stored procedures may return multiple
          > result sets, so you have to parse each result set to get all the
          > information. sp_helpdb returns two result sets. Books Online is an[/color]
          excellent[color=blue]
          > reference for all the system stored procedures - they are all listed under
          > the "System Stored Procedures" topic (at least assuming you have SQL2000 -
          > you didn't mention your version).
          >
          > Simon
          >
          >[/color]


          Comment

          • Erland Sommarskog

            #6
            Re: query/read database size?

            Rob Wahmann (dotcomstudio@s bcglobal.net) writes:[color=blue]
            > Alrighty then... I've got the sp_helpdb prodecure returning results just
            > fine but it's showing the entire size of the database + log file. Is
            > there a way to specify the data file size only? I appreciate any tips![/color]

            If you specify a database name, you get two result sets, whereof the
            second gives you sizes per file. You can also use sp_helpfile to get that
            second result set only.

            See further in Books Online. (Which you may not have installed, but see
            my signature.)



            --
            Erland Sommarskog, SQL Server MVP, sommar@algonet. se

            Books Online for SQL Server SP3 at
            Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.

            Comment

            Working...