Re: sp_spaceused reporting anomolies?
From: Jacco Schalkwijk (NOSPAMjaccos_at_eurostop.co.uk)
Date: 03/17/04
- Next message: Rand Boyd [MSFT]: "Re: Installation is not possible on W2003"
- Previous message: Geoff N. Hiten: "Re: Remote restore question"
- In reply to: mikron2: "sp_spaceused reporting anomolies?"
- Next in thread: mikron2: "Re: sp_spaceused reporting anomolies?"
- Reply: mikron2: "Re: sp_spaceused reporting anomolies?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 17 Mar 2004 21:34:21 -0000
What you see is normal behaviour if you have a table without a clustered
index and you delete all the rows from it. All the datapages will still be
assigned to the table, even if they are empty. You can reclaim the pages
taken up by the table by either:
- using TRUNCATE TABLE TableX if the table is not referenced by foreign keys
- creating a clustered index on the table and dropping it again, although,
as it in general is a good idea to have a clustered index on a table, it
might be better to leave it there.
-- Jacco Schalkwijk SQL Server MVP "mikron2" <anonymous@discussions.microsoft.com> wrote in message news:F25A2C90-F5BC-4D3A-BAC5-BD6E80D1D8EE@microsoft.com... > Here's the DDL script for the table in question: > > CREATE TABLE [dbo].[TableX] ( > [ColA] [int] IDENTITY (1, 1) NOT NULL , > [ColB] [varchar] (40) NULL , > [ColC] [varchar] (30) NOT NULL , > [ColD] [int] NULL , > [ColE] [datetime] NULL , > [ColF] [smallint] NULL , > [ColG] [varchar] (30) NULL , > [ColH] [varchar] (30) NULL , > [ColI] [varchar] (30) NULL , > [ColJ] [varchar] (30) NULL , > [ColK] [float] NULL , > [ColL] [float] NULL , > [ColM] [float] NULL , > [ColN] [smallint] NULL , > [ColO] [smallint] NULL > ) ON [PRIMARY] > GO > > ALTER TABLE [dbo].[TableX] ADD > CONSTRAINT [PK_TableX] PRIMARY KEY NONCLUSTERED > ( > [ColA], > [ColC] > ) ON [PRIMARY] > GO > > When I run sp_spaceused on the table, here's what I get: > > name rows reserved data index_size unused > -------- ------ ------------- ------------- ------------- ---------------- -- > TableX 0 121440 KB 117216 KB 56 KB 4168 KB > > Now, if the table has zero rows (I did a 'select * from TableX' and got the same result), why is there ANY space used? I've also run about every DBCC command I can think of that would pertain to this problem - no change in the sp_spaceused output. Also, when I ran the 'select * from TableX' query, it took ~ 5 seconds for the query to execute. I don't know if the table was truncated or 'delete from TableX' was executed. > > There are a handful of tables in the database with this same problem (not nearly as drastic!), so I'm wondering if there is some database corruption at work here that isn't being reported by DBCC CHECKDB, etc. > > TIA for any help. > > Mike Stuart > mstuart_nospam@gates.com >
- Next message: Rand Boyd [MSFT]: "Re: Installation is not possible on W2003"
- Previous message: Geoff N. Hiten: "Re: Remote restore question"
- In reply to: mikron2: "sp_spaceused reporting anomolies?"
- Next in thread: mikron2: "Re: sp_spaceused reporting anomolies?"
- Reply: mikron2: "Re: sp_spaceused reporting anomolies?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|