I have two tables in which, more or less, one contains a subset of data of the other one. There is some data I delete from the first table, which is inserted in the second one as historical data.
These are the defintions:
CREATE TABLE [dbo].[CIC_DESLUNGHE](
[CD_CIC_DESLUNGHE] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NULL,
CONSTRAINT [PK_CIC_DESLUNGHE] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 99) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[CIC_DESLUNGHE_STORICI](
[CD_CIC_DESLUNGHE_STORICI] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE_STORICI] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI_STORICI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_CIC_DESLUNGHE_STORICI_1] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE_STORICI] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
The second table contains a subset of data that I need it as historicization of my data.
Table Rows TotalSpace MB
--------------------- ---------- -------------
CIC_DESLUNGHE_STORICI 12.709.497 48214,75
CIC_DESLUNGHE 24.827.337 5675,49
What leaves me astonished is that the total storage space utilized. The subset table use 10 times the space of the other.
Any idea why this is happening?
I tried rebuilding the clustered index of CIC_DESLUNGHE_STORICI
, but the storage only dropped from 48 GB to 47 GB.
-- EDIT --
This is the result I got with the query of Josh Darnell