473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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
Jul 20 '05 #1
5 33624
"Rob Wahmann" <do**********@sbcglobal.net> wrote in message
news:bW********************@newssrv26.news.prodigy .com...
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


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

exec sp_helpdb MyDB

Simon
Jul 20 '05 #2
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" <sq*@hayes.ch> wrote in message
news:3f**********@news.bluewin.ch...
"Rob Wahmann" <do**********@sbcglobal.net> wrote in message
news:bW********************@newssrv26.news.prodigy .com...
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


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

exec sp_helpdb MyDB

Simon

Jul 20 '05 #3
"Rob Wahmann" <do**********@sbcglobal.net> wrote in message
news:eb********************@newssrv26.news.prodigy .com...
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


<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
Jul 20 '05 #4
Thanks again! I'm going to toy around with how to call the stored proc.

Regards,

Rob

"Simon Hayes" <sq*@hayes.ch> wrote in message
news:3f********@news.bluewin.ch...
"Rob Wahmann" <do**********@sbcglobal.net> wrote in message
news:eb********************@newssrv26.news.prodigy .com...
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


<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

Jul 20 '05 #5
Rob Wahmann (do**********@sbcglobal.net) writes:
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!


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, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Wm | last post by:
I have a query that I expect to return 3 or 4 entries -- but I seem to be getting only the most recent entry, repeated 4 times. What am I doing wrong here? $query="SELECT...
11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
3
by: Nick Truscott | last post by:
<? // scoreinput.php - input a match score when match selected from list ?> <html> <head> <basefont face="Verdana"> </head> <body>
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
11
by: 73blazer | last post by:
We are migrating a customer from Version 7.1 FP3, to Version 8.2 (8.1 FP8). For the most part, things are faster, but there is one query that is much much slower, and it is a query that is used all...
0
by: quang | last post by:
I have a subform within my results form that I use to display the results of my queries. Here is the problem: once the query has run and its results are displayed in my subform - if you make any...
3
by: cover | last post by:
I have a table with 50 fields that receive input depending on whether that input came in from a 'shaker' form or a 'conveyor' form. Input from the 'conveyor' form might populate 25 fields while...
5
by: Sam | last post by:
Hi, I have one table like : MyTable {field1, field2, startdate, enddate} I want to have the count of field1 between startdate and enddate, and the count of field2 where field2 = 1 between...
6
by: Ashlewis | last post by:
Im currently using a string to store my query in VB. It seems to work perfectly fine for short queries. But as my queries become longer and longer, this method just doesnt seem to work. Im using...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.