I have a small script below which uses sp_MSforeachtable and sp_spaceused in combination to return the size in KB's of each user table in the database.
I run the script against my development and test databases which have approximately the same number of records in each user table.
CREATE TABLE #temp
(TableName NVARCHAR (128), RowsCnt VARCHAR (11), ReservedSpace VARCHAR(18),
DataSpace VARCHAR(18), CombinedIndexSpace VARCHAR(18), UnusedSpace VARCHAR(18))
EXEC sp_MSforeachtable 'INSERT INTO #temp (TableName, RowsCnt, ReservedSpace, DataSpace, CombinedIndexSpace, UnusedSpace)
EXEC sp_spaceused ''?'', FALSE'
SELECT TableName, RowsCnt, ReservedSpace, DataSpace, CombinedIndexSpace,
UnusedSpace
FROM #temp
ORDER BY TableName
DROP TABLE #temp
I export the results to a spreadsheet which sums the size of the dataspace and combinedindexspace for each table to give a total of around 1.5 MB for both Test and development.
If I execute sp_spaceused on its own it returns a database size of approx 252 MB for Development and 8 MB for Test. So how do I explain the difference in sizes. Is this a re-indexing issue?
Thanks
The risk with keeping an open mind is having your brains fall out.
Shaunk
I run the script against my development and test databases which have approximately the same number of records in each user table.
CREATE TABLE #temp
(TableName NVARCHAR (128), RowsCnt VARCHAR (11), ReservedSpace VARCHAR(18),
DataSpace VARCHAR(18), CombinedIndexSpace VARCHAR(18), UnusedSpace VARCHAR(18))
EXEC sp_MSforeachtable 'INSERT INTO #temp (TableName, RowsCnt, ReservedSpace, DataSpace, CombinedIndexSpace, UnusedSpace)
EXEC sp_spaceused ''?'', FALSE'
SELECT TableName, RowsCnt, ReservedSpace, DataSpace, CombinedIndexSpace,
UnusedSpace
FROM #temp
ORDER BY TableName
DROP TABLE #temp
I export the results to a spreadsheet which sums the size of the dataspace and combinedindexspace for each table to give a total of around 1.5 MB for both Test and development.
If I execute sp_spaceused on its own it returns a database size of approx 252 MB for Development and 8 MB for Test. So how do I explain the difference in sizes. Is this a re-indexing issue?
Thanks
The risk with keeping an open mind is having your brains fall out.
Shaunk