<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LOB_DATA &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/lob_data/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Mon, 14 Aug 2017 20:19:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Server: Script to check the Allocation Units of a Table</title>
		<link>https://www.dbrnd.com/2017/08/sql-server-script-to-check-the-allocation-units-of-a-table/</link>
					<comments>https://www.dbrnd.com/2017/08/sql-server-script-to-check-the-allocation-units-of-a-table/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 06 Aug 2017 16:16:27 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Allocation unit]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[IN_ROW_DATA]]></category>
		<category><![CDATA[LOB_DATA]]></category>
		<category><![CDATA[ROW_OVERFLOW_DATA]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5787</guid>

					<description><![CDATA[In this post, I am sharing a script to check the available allocation units on a Table in SQL Server. When you create a table and stored data, it stored into different types of allocation units like IN_ROW_DATA, LOB_DATA, ROW_OVERFLOW_DATA. Already shared a couple of articles on the importance of allocation units like ROW_OVERFLOW_DATA. When [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-check-the-allocation-units-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20check%20the%20Allocation%20Units%20of%20a%20Table" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-check-the-allocation-units-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20check%20the%20Allocation%20Units%20of%20a%20Table" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-check-the-allocation-units-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20check%20the%20Allocation%20Units%20of%20a%20Table" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-check-the-allocation-units-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20check%20the%20Allocation%20Units%20of%20a%20Table" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-check-the-allocation-units-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20check%20the%20Allocation%20Units%20of%20a%20Table" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-check-the-allocation-units-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20check%20the%20Allocation%20Units%20of%20a%20Table" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-check-the-allocation-units-of-a-table%2F&#038;title=SQL%20Server%3A%20Script%20to%20check%20the%20Allocation%20Units%20of%20a%20Table" data-a2a-url="https://www.dbrnd.com/2017/08/sql-server-script-to-check-the-allocation-units-of-a-table/" data-a2a-title="SQL Server: Script to check the Allocation Units of a Table"></a></p><p>In this post, I am sharing a script to check the available allocation units on a Table in SQL Server. When you create a table and stored data, it stored into different types of allocation units like IN_ROW_DATA, LOB_DATA, ROW_OVERFLOW_DATA.</p>
<p>Already shared a couple of articles on the importance of allocation units like ROW_OVERFLOW_DATA. When your data are exceeding 8KB pages, it stores into ROW_OVERFLOW_DATA which is also called internal fragmentation. </p>
<p>Using this script, you will get to know different allocations related information including page start number which helps you to do further require analysis on your table. </p>
<pre class="crayon-plain-tag">DECLARE @object SYSNAME = 'table_name'

SELECT
    OBJECT_NAME ([sp].[object_id]) AS [Object Name],
    [sp].[index_id] AS [Index ID],
    [sp].[partition_id] AS [Partition ID],
        [sa].[allocation_unit_id] AS [Alloc Unit ID],
    [sa].[type_desc] AS [Alloc Unit Type],
    '(' + CONVERT (VARCHAR (6),
        CONVERT (INT,
            SUBSTRING ([sa].[first_page], 6, 1) +
            SUBSTRING ([sa].[first_page], 5, 1))) +
    ':' + CONVERT (VARCHAR (20),
        CONVERT (INT,
            SUBSTRING ([sa].[first_page], 4, 1) +
            SUBSTRING ([sa].[first_page], 3, 1) +
            SUBSTRING ([sa].[first_page], 2, 1) +
            SUBSTRING ([sa].[first_page], 1, 1))) +
    ')' AS [First Page],
    '(' + CONVERT (VARCHAR (6),
        CONVERT (INT,
            SUBSTRING ([sa].[root_page], 6, 1) +
            SUBSTRING ([sa].[root_page], 5, 1))) +
    ':' + CONVERT (VARCHAR (20),
        CONVERT (INT,
            SUBSTRING ([sa].[root_page], 4, 1) +
            SUBSTRING ([sa].[root_page], 3, 1) +
            SUBSTRING ([sa].[root_page], 2, 1) +
            SUBSTRING ([sa].[root_page], 1, 1))) +
    ')' AS [Root Page],
    '(' + CONVERT (VARCHAR (6),
        CONVERT (INT,
            SUBSTRING ([sa].[first_iam_page], 6, 1) +
            SUBSTRING ([sa].[first_iam_page], 5, 1))) +
    ':' + CONVERT (VARCHAR (20),
        CONVERT (INT,
            SUBSTRING ([sa].[first_iam_page], 4, 1) +
            SUBSTRING ([sa].[first_iam_page], 3, 1) +
            SUBSTRING ([sa].[first_iam_page], 2, 1) +
            SUBSTRING ([sa].[first_iam_page], 1, 1))) +
    ')' AS [First IAM Page]
FROM
    sys.system_internals_allocation_units AS [sa],
    sys.partitions AS [sp]
WHERE
    [sa].[container_id] = [sp].[partition_id]
AND [sp].[object_id] =
(CASE WHEN (@object IS NULL)
    THEN [sp].[object_id]
    ELSE OBJECT_ID (@object)
END)</pre> </p>
<p><a href="https://www.sqlskills.com/blogs/paul/inside-the-storage-engine-sp_allocationmetadata-putting-undocumented-system-catalog-views-to-work/" target="_blank">Reference is taken from sqlskills.com:</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/08/sql-server-script-to-check-the-allocation-units-of-a-table/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
