Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sp_spaceused - database_size - sql 2000

Posted on 2010-09-15
5
Medium Priority
?
498 Views
Last Modified: 2012-05-10
There is store procedure sp_spaceused this give information about database size and some other database related information. One of the output column is database_size

Does anyone know in which table "database_size" field is stored? thanks
0
Comment
Question by:tech2010
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 70

Expert Comment

by:Scott Pletcher
ID: 33683333
It's not directly stored in that way.  That value is likely a summation of other values in system tables.

In SQL 2000, I think you have to use dbo.sysindexes to get the relevant sizes.  Note that even a table w/o any index is in sysindexes, with an indid = 0 (0 = heap, 1 = clus index).
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 33683368
Its from dbo.sysfiles and the query involved here:

select sum(convert(bigint,case when status & 64 = 0 then size else 0 end)) dbsize,
sum(convert(bigint,case when status & 64 <> 0 then size else 0 end)) logsize
            from dbo.sysfiles
0
 
LVL 70

Expert Comment

by:Scott Pletcher
ID: 33683480
You can always go to master and look at the code for
sp_spaceused

Yeah, sysindexes wouldn't have log size, only data size.
0
 

Author Comment

by:tech2010
ID: 33683600
how can sum data + log size and then use xp_sendmail to fire an email if total sum is > 100
0
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 2000 total points
ID: 33684197
>> how can sum data + log size

It can be summed like this

select sum(convert(bigint,case when status & 64 = 0 then size else 0 end)) +
sum(convert(bigint,case when status & 64 <> 0 then size else 0 end)) total_size
from dbo.sysfiles

Send the result of the above query using xp_sendmail like:

EXEC xp_sendmail @recipients = 'emailid',
   @query = 'select sum(convert(bigint,case when status & 64 = 0 then size else 0 end)) + sum(convert(bigint,case when status & 64 <> 0 then size else 0 end)) total_size from dbo.sysfiles',
   @subject = 'Result',
   @message = 'Result of the query:',
   @attach_results = 'TRUE', @width = 250
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question