Sp_spaceused Database Size

Oct 19, 2004

How is it that the value returned by sp_spaceused is larger than the actual database size and unallocated space be negative? For example sp_spaceused retruns the following for one of our databases.

database_size = 52022.31 MB
unallocated space = -16462.47 MB

reserved = 69559520 KB
data = 68007688 KB
index_size = 1463456 KB
unused = 88376 KB

That does not make much sense to me how the reserved size and even data size can be larger than the database_size.

This database was 85 gigs yesterday but we were running extremely short on disk space so I was forced to do a shrink. I did update stats for the database as well.

Thanks much.

View 9 Replies


ADVERTISEMENT

How Do I Run Sp_spaceused For All Tables In A Database?

Oct 18, 2007

Hi,

I am struggling to understand how to run the sp_spaceused sproc for all tables in a database.

I know how to use it for one table but how would I replicate it automatically for each table in a given database?

Regards,

Ian.

View 12 Replies View Related

Executing SP_SpaceUsed For Tables In A Other Database With EXEC

Jul 20, 2005

HiI'm executing SP_SpaceUsed in a stored procedure like this :Exec ('SP_SpaceUsed '+ @table)This works great but when i want to execute it for a table in a otherdatabase i'm running in to troubles. Things i tried is this :Exec ('USE <DB> ; SP_SpaceUsed '+ @table) -->not working (uncorrectsyntax)Exec ('USE <DB> ; Master.dbo.SP_SpaceUsed '+ @table) -->not working(uncorrect syntax)Exec ('SP_SpaceUsed <DB>.dbo.'+ @table) --> not working (uncorrectsyntax)Exec ('Master.dbo.SP_SpaceUsed <DB>.dbo.'+ @table) -->not working(uncorrect syntax)Could someone give me a clueThanx,Hennie de Nooijer

View 1 Replies View Related

Table Size And Database Size

Mar 2, 2008

Hi,
i use this script that show me the size of each table and do the sum of all the table size.

SELECT
X.[name],
REPLACE(CONVERT(varchar, CONVERT(money, X.[rows]), 1), '.00', '') AS [rows],
REPLACE(CONVERT(varchar, CONVERT(money, X.[reserved]), 1), '.00', '') AS [reserved],
REPLACE(CONVERT(varchar, CONVERT(money, X.[data]), 1), '.00', '') AS [data],
REPLACE(CONVERT(varchar, CONVERT(money, X.[index_size]), 1), '.00', '') AS [index_size],
REPLACE(CONVERT(varchar, CONVERT(money, X.[unused]), 1), '.00', '') AS [unused]
FROM
(SELECT
CAST(object_name(id) AS varchar(50)) AS [name],
SUM(CASE WHEN indid < 2 THEN CONVERT(bigint, [rows]) END) AS [rows],
SUM(CONVERT(bigint, reserved)) * 8 AS reserved,
SUM(CONVERT(bigint, dpages)) * 8 AS data,
SUM(CONVERT(bigint, used) - CONVERT(bigint, dpages)) * 8 AS index_size,
SUM(CONVERT(bigint, reserved) - CONVERT(bigint, used)) * 8 AS unused
FROM sysindexes WITH (NOLOCK)
WHERE sysindexes.indid IN (0, 1, 255)
AND sysindexes.id > 100
AND object_name(sysindexes.id) <> 'dtproperties'
GROUP BY sysindexes.id WITH ROLLUP) AS X
ORDER BY X.[name]

the problem is that the sum of all tables is not the same size when i make a full database backup.
example of this is when i run this query against my database i see a sum of 111,899 KB that they are 111MB,but when
i do full backup to that database the size of this full backup is 1.5GB,why is that and where this size come from?

THX

View 5 Replies View Related

SQL 2005 Resize Initial Log Size: MODIFY FILE Failed. Specified Size Is Less Than Current Size.

Sep 4, 2007


I am trying to resize a database initial log file from 500M to 2M. I€™m using€?

ALTER DATABASE <DBNAME> MODIFY FILE ( NAME = <DBLOGFILENAME, SIZE = 2 ) "



And I'm getting "MODIFY FILE failed. Specified size is less than current size." I tried going into the database properties and setting the log file to 2M, but it doesn€™t keep the changes.



Any help with this process?

View 1 Replies View Related

Sp_spaceused

May 28, 2004

When I run sp_spaceused I will get something like:

database_name . database_size . unallocated space
------------------ ----------------- ------------------
. . . DBA . . . . . . . 2.50 MB . . . . . 0.07 MB


reserved . . . . . . data . . . . . . . index_size . . . . unused
------------------ ------------------ ------------------ ------------------
1720 KB . . . . . . . 888 KB . . . . . . 648 KB . . . . . .184 KB

Is there any way to load this info into a Table?
I'm having trouble because there are (2) result sets returned.

View 1 Replies View Related

Sp_spaceused

Oct 18, 2000

I am using the sp_spaceused system stored procedure to identify tables in my database that are large. I have two questions. Can anyone help me sort this list. I assume this is returned in clustered order, but I want to order the list by rows. Also, when I run this sp_spaceused stored proc, on some of my tables I get a negative value returned under the 'index_size' and 'unused' columns in my result set. How can this be.

View 1 Replies View Related

Sp_spaceused

Jan 12, 2000

I am looking for an accurate way to calculate database size and
unused space.

I do NOT want the log size calculated into the database size or
the space unused.

Thank you

View 2 Replies View Related

Sp_spaceused

Sep 16, 2002

on some of our sql 6.5 databases the space available is shown as 0MB. I realise that I must run sp_spaceused to get an accurate result, but the results I then get are slightly confusing. All I want to know is the space left in both the database and the log - can I get a reading for both?. Sometimes the unused space is shown as a negative number. Can anyone advise since books online is fairly unspecific.

(the total script that i run incidentaly is:

exec sp_spaceused
go
DBCC checktable (sysindexes)
go
DBCC checktable (syslogs)
go
exec sp_spaceused @updateusage=true
go)

Thanks

View 3 Replies View Related

Sp_spaceused

Jul 27, 1999

Can someone please explain the outputs below of the sp_spaceused stored procedure.

database_name database_size unallocated space
------------------------------ ------------------ ------------------
Employees 5054.00 MB 1441.93 MB

reserved data index_size unused
------------------ ------------------ ------------------ ------------------
3698758 KB 2770552 KB 917274 KB 10932 KB

View 1 Replies View Related

Sp_spaceused

Jun 29, 2001

hi,
I used sp_spaceused 'owner.tablename' and it shows index size as 24kb whereas there is no index on this table.
I thought may be it's not showing the right statistics so I update the statistics but it is still showing the same .
what is happening?
I am using SQl 2k/Win2k.
TIA.

View 2 Replies View Related

Sp_spaceused

Sep 7, 2004

can someone please explain what reserved, data and unused represent?

View 4 Replies View Related

Sp_spaceused

Jul 20, 2005

Hi,In our environment sp-spaceused returns:Allocated: 500Unallocated: -100Enterprise Database Taskpad shows that our total database size = 400 MB(320 used; 80 unused)Windows Explorer shows also that MDF file is more or less 400 MB.What does sp_spaceused exactly ???How do I SELECT the 320;80 of the taskpad with a query ???Greetings,Arno de Jong, The Netherlands.

View 1 Replies View Related

Question On Sp_spaceused

Nov 2, 1999

What does sp_spaceused show nonzero sizes for data, reserved and index size when the table is empty?
It also does this on 6.5.

View 1 Replies View Related

Sp_spaceused Riddle....

Mar 15, 1999

I have ran sp_spaceused (SQL 6.5 SP4) on my database (4000MB Data, 500 Log) and received the following output for "Reserved" : 4412390 KB. Note that this is more than 4000MB. I checked and made sure my data and log were truly separated...

Just to make sure, I added 2000MB more data space. Sp_spaceused now returned the following for reserved: 3493220 KB.

I am wondering why the allocation dropped, while no user activity was taking place during the process of growing the database....sp_spaceused reported data size first at 2725532, then at 1806314. Any ideas? A bug? Did the database fill up and begin using log pages...?

Any help is GREATLY appreciated...

Thanks!

Dean

View 2 Replies View Related

Sp_spaceused Result

Oct 26, 2006

Hi,
I ran sp_spaceused against a DB table, and got -160K in the field "unused". If anybody can explain what this negative number means?
We have a problem with performance. It's extremly slow. The table contains 600,000 records. Even simple select * from <table> (table scan) takes 6 minutes. This is SQL Server2000.
Any help is appreciated.

View 5 Replies View Related

Enhanced Sp_spaceused

Aug 16, 2005

I can't remember if I posted this already or not:

CREATE PROCEDURE sp_space @sortbyrows bit=0 AS
SET NOCOUNT ON
select cast(object_name(id) as varchar(50)) AS name, sum(CASE WHEN indid<2 THEN rows END) AS rows,
sum(reserved)*8 AS reserved, sum(dpages)*8 AS data, sum(used-dpages)*8 AS index_size, sum(reserved-used)*8 AS unused
from sysindexes with (nolock) where indid in(0,1,255) and id>100
GROUP BY id with rollup
ORDER BY CASE WHEN @sortbyrows=1 THEN sum(CASE WHEN indid<2 THEN rows END) ELSE sum(reserved)*8 END desc

Usage:

EXEC sp_space --show stats sorted by reserved space size
EXEC sp_space 1 --show stats sorted by row count

It basically displays the results of sp_spaceused, but broken out by each table, and it rolls it up to a grand total. Naturally, for the most accurate results you should run DBCC UPDATEUSAGE before running this sproc.

View 10 Replies View Related

Sp_spaceused Equivalent In CE?

Oct 3, 2007

I am looking for a way to programatically determine the size of the data contained in a table, much like the sp_spaceused proc in SQL Server.


Thanks.

View 3 Replies View Related

Sp_spaceused Question !

May 10, 2007

name
rows
reserved
data
index_size
unused

Table1
2553136
294424 KB
293176 KB
1072 KB
176 KB





When I run sp_spaceused on a table called Table1, I get numbers as shown above.



I have a clustered Index on a datetime column AND that is the only index on the table.



So according to my calculations Index Size should be 2553136 (No. Of Rows) X (8 (DataType of DateTime) + 4 (Uniquifier) )



So the number I should be seeing in the Index Size column = 2553136 * 12 = 30637 KB, why am I only seeing 1072 KB ?



Where am I going wrong in my calculations.



To be more specific -- how do I calculate the Size Occupied by Indexes on a Particular Table ??



Thanks

View 5 Replies View Related

Getting Database Size And Log Size

Aug 11, 2000

Hi,
I am using
exec sp_helpdb
go
dbcc sqlperf(logspace) for
getting database size and log size. Is this gives the correct
database size and log size or Is there any other way to get the logsize and database size by means of query analyzer.

Thanks in Advance.

Seenu. S

View 4 Replies View Related

EXEC Sp_msforeachtable 'sp_spaceused ''?'''

Feb 25, 2008

What does the following SQL code mean?
 EXEC sp_msforeachtable 'sp_spaceused ''?'''

View 2 Replies View Related

Quick Question On Sp_spaceused

Jun 10, 2004

I executed sp_spaceused on the db ang got following results
database_name:myDB
database_size: 1017.75 MB
unallocated space :104.13 MB

reserved : 309752 KB
data : 306832 KB
index_size : 1936 KB
unused : 984 KB

If we add reserved,data,index_size and unused up , we will get around 600MB.But the database has size of 1G. Could anyone tell me why?

View 11 Replies View Related

Monitoring DB Growth With Sp_spaceused

Jun 19, 2000

Hello,
I started to write a stored procedure to insert into a temp table from sp_spaceused but couldn't get the format right. I did a search in the swynk archive and saw that some people have solved this but I couldn't see any example code. Does anyone have scripts they've written to gather db size info using sp_spaceused or some other mechanism?
Thanks in advance,
Dan

View 2 Replies View Related

Sp_spaceused With Negative Numbers?

Mar 1, 1999

Hello:

I have gotten the following information from sp_spaceused:

----------------------------------------------------------------------
database_name database_size unallocated space
------------------------------ ------------------ ------------------
EP_tran2 700.00 MB 273.21 MB

reserved data index_size unused
------------------ ------------------ ------------------ ------------------
437034 KB 295106 KB 1447796 KB -1305868 KB
--------------------------------------------------------------------

I unfortunately since this is for a test database that I have put the data and log on the same device.

My questions are:

1) Why do I have negative numbers?

2) Should I be concerned about this?

3) for a live database can I drop the log and put the log on another device? What do I need to do?

4) has anybody seen this before?

5)what can I use to get accurate numbers?

THanks. Any information will be greatly appreciated.

DAvid Spaisman

View 1 Replies View Related

Sp_spaceused - Please Ignore The Xp_fixeddrives

Apr 19, 2006

hi,

sp_spaceused return 2 set of results. How do i store this result into a table?

Thanks

View 5 Replies View Related

Sp_spaceused - Too Much Unused Space

Jul 20, 2005

On a production database, there is a 2GB database, when I runsp_spaceused it indicates a very high quanity of unused space. Thedatabase has been shrunk & free space sent to the OS. Why is thisvalue so high, what can I do to reclaim the space?database_name database_size unallocated space------------------------------------------------------------------------------DB_00001 2004.13 MB 49.64 MBreserved data index_size unused------------------ ------------------ --------------------------------1531248 KB 412720 KB 165168 KB 953360 KB

View 5 Replies View Related

The Database File Is Larger Than The Configured Maximum Database Size.

Mar 20, 2007

I'm getting this error while trying to insert records into a SQL Server Compact Edition database. I have pasted my connection string that was used when creating the database as well as for accessing that same database from my Windows application.

Thanks for any help any of you can give!

Data Source=OnTheGo.sdf;Encrypt Database=True;Password=<password>;Max Database Size=4091

View 3 Replies View Related

Enterprise Manager Versus Sp_spaceused

Jun 29, 1999

When comparing the data space available (Edit Database dialog within Enterprise Manager) to sp_spaceused, I occasionally generate numbers that have discrepancies.

Example
Enterprise Manager shows data space available = 160.43 MB
sp_spaceused (Unallocated space = 397 MB) less log space (200 MB) = 197 MB

Even after I run (sp_spaceused @updateusage = 'true'), the problem is not resolved. Are there any known issues with space being calculated incorrectly from within Enterprise Manager? Should I not rely on Enterprise Manager and stick with sp_spaceused to find out database usage? Are there any other methods which will resolve this problem? Any help would be appreciated.

Thanks,
Karl

View 3 Replies View Related

Sp_spaceused Reports Over 40 GB Unused For A Table

Jul 20, 2005

I have a large table that I recently purged a year of data from.However, the table size in sp_spaceused hasn't decreased as much as Iwould expect. (there are no text or large object columns on thistable, BTW) Running sp_spaceused on the table shows the following.rows reserved data index size unusedTABLE_NAME23470880 67790808 KB 18116312 KB 3211616 KB 46462880 KBI ran a dbcc indexdefrag on all indexes on the table last night,including the clustered index, and I'm still seeing pretty much thesame amount of space reported as unused.The one thing that I haven't done yet is to run the sp_spaceused onthis table with the @updateusage flag set to true as I need to do thisafterhours to reduce contention. I will attempt this tonight andreport on the results.Here's DBCC SHOWCONTIG OUTPUT for the table:DBCC SHOWCONTIG scanning 'TABLE_NAME' table...Table: 'TABLE_NAME' (917578307); index ID: 1, database ID: 7TABLE level scan performed.- Pages Scanned................................: 2264447- Extents Scanned..............................: 285484- Extent Switches..............................: 287092- Avg. Pages per Extent........................: 7.9- Scan Density [Best Count:Actual Count].......: 98.59%[283056:287093]- Logical Scan Fragmentation ..................: 0.04%- Extent Scan Fragmentation ...................: 3.19%- Avg. Bytes Free per Page.....................: 2418.9- Avg. Page Density (full).....................: 70.12%DBCC execution completed. If DBCC printed error messages, contact yoursystem administrator.Looking through the history of the group, the one thing that seems toremedy this problem consistantly is to bcp out all the data, trunc thetable and bcp all the data back in. This is not really a possibilityfor me due to the size of the table and the availability expectationsof my customers. Is there anything that I forgot to check? Do youthink that it's just a matter of incorrect statistics in sp_spaceused?Thanks in advance:Matt

View 4 Replies View Related

Database File Is Larger Than The Configured Max Database Size.

Feb 18, 2008

Hello,

I am developing a smart device application with Visual Studio .Net 2005 and SQL Server Compact Edition database. And also using merge replication to synchronize the data from the mobile device to the SQL Server.

My database size is around 350MB. So when I am trying to synchronize this is the error message that I get.
" The database file is larger than the configured maximum database size. The setting takes effect on the first concurrent database connection only.[Required Max Database size ( in MB; 0 if unknown)=129].

I tried changing the Max database size in the connection string and my connection string looks as follows and still did not have any luck.

connstr= "Data Source=Storage CardItems.sdf;Max Database Size=500;"

Any help regarding this would be appreciated.

Thank you
.

View 6 Replies View Related

Sp_spaceused Report Negative Number For Unused

May 20, 2000

Could some one help me to explain what does it means when I ran sp_spaceused on the database it reported ex. -15430kb for unused. Does this mean that the index ran out off space. Do I need to increase space for the database. I will try to run the dbcc check hope it will fix the problem.

Thanks.

View 1 Replies View Related

Sp_spaceused Shows Negative Unallocated Space

Mar 1, 2005

Hi All,

When i run sp_spaceused on one of my database, PROD, it gives the following output

database_name: PROD
database_size: 4268.00 MB
unallocated space: -789.82 MB


reserved: 4654920 KB
data: 2929008 KB
index_size: 327272 KB
unused: 1398640 KB

Why is that the unallocated space is negative ?

On the drive where the datafiles resides there is enough free space . Also, the datafile and transaction are set to auto grow with unlimited file growth

FYI - the OS is Windows 2000 and the DB is SQL Server 2000 with SP3

Appreciate your time and help on this.

View 1 Replies View Related

How Do I Select A Column From Sp_spaceused Into A Local Variable?

Jul 20, 2005

I want to look at the size of the current database, so I can create a newone if it gets too big (we are working around the 2gb MSDE limit for ourcustomers).I would like to do something like this:DECLARE @size INTEGERexecute BLOB0000.dbo.sp_spaceusedand make @size = the database_size column value that sp_spaceused returns.Any way to do this?Thanks.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved