﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / Used Pages vs Data Pages / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 02:10:31 GMT</lastBuildDate><ttl>20</ttl><item><title>Used Pages vs Data Pages</title><link>http://www.sqlservercentral.com/Forums/Topic1385087-391-1.aspx</link><description>Hi,I executed the following code to determine the size that a certain table takes no the database:[code="sql"]select o.name AS Table_Name,i.index_id, i.type as i_type, p.rows,a.total_pages, a.used_pages, a.data_pages, a.type alloc_typefrom sys.objects oinner join sys.indexes i on o.object_id = i.object_idinner join sys.partitions as p on i.object_id = p.object_id and i.index_id = p.index_id  inner join sys.allocation_units as a on p.partition_id = a.container_id where o.is_ms_shipped = 0  and o.name= 'AlertasUtilizadorLog'order by o.name, i.typeexec sp_spaceused 'AlertasUtilizadorLog'[/code]I also executed the sp_spaceused to compare both results.The output was:[code="other"]Table_Name		index_id	i_type	rows	        total_pages	        used_pages	        data_pages	alloc_typeAlertasUtilizadorLog	0		0		319		57			54			53			1AlertasUtilizadorLog	0		0		319		209			208			0			2AlertasUtilizadorLog	2		2		319		4			4			2			1name	                        rows	        reserved	data	        index_size	unusedAlertasUtilizadorLog	319        	2160 KB	2088 KB	40 KB	        32 KB[/code]the reserved size is the sum of total_pages.the data size is the sum of data_pages for alloc_type = 1 and used_pages for alloc_type = 2 and index_type &amp;lt;= 1 (CLUSTERED OR HEAP).the unused size is the sum of total_pages less the sum of used_pages.now comes my "problem"... the sum of used_pages for indexes (i_type &amp;gt; 1) is 4 and sp_spaceused says 5...How is that?! I can get that value, just subtract used_pages to total_pages and I get that value but why hasn't the sum of all indexes have that value?!Just one more... total_pages or reserved is the size the data occupies on disk... but used_pages isn't suppose to be the data space or does it have "trash" and the real data is data_pages?Thanks,Pedro</description><pubDate>Thu, 15 Nov 2012 04:44:04 GMT</pubDate><dc:creator>PiMané</dc:creator></item></channel></rss>