<?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>Partitioned View &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/partitioned-view/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, 28 Aug 2017 19:46:33 +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: Implement Table Partition in Non Enterprise Edition (Use Partitioned View)</title>
		<link>https://www.dbrnd.com/2017/09/sql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view/</link>
					<comments>https://www.dbrnd.com/2017/09/sql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 03 Sep 2017 16:16:45 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Partitioned View]]></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[Table Partition]]></category>
		<category><![CDATA[table partitioning]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6022</guid>

					<description><![CDATA[In this post, I am sharing a full demonstration of the concept of Partitioned view in SQL Server. Using Partitioned view, you can implement Table Partitioning in the Non-Enterprise Edition of SQL Server because Table Partition is the feature of SQL Server Enterprise Edition. Many small level companies are searching for this kind of solution, [&#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%2F09%2Fsql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view%2F&amp;linkname=SQL%20Server%3A%20Implement%20Table%20Partition%20in%20Non%20Enterprise%20Edition%20%28Use%20Partitioned%20View%29" 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%2F09%2Fsql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view%2F&amp;linkname=SQL%20Server%3A%20Implement%20Table%20Partition%20in%20Non%20Enterprise%20Edition%20%28Use%20Partitioned%20View%29" 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%2F09%2Fsql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view%2F&amp;linkname=SQL%20Server%3A%20Implement%20Table%20Partition%20in%20Non%20Enterprise%20Edition%20%28Use%20Partitioned%20View%29" 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%2F09%2Fsql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view%2F&amp;linkname=SQL%20Server%3A%20Implement%20Table%20Partition%20in%20Non%20Enterprise%20Edition%20%28Use%20Partitioned%20View%29" 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%2F09%2Fsql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view%2F&amp;linkname=SQL%20Server%3A%20Implement%20Table%20Partition%20in%20Non%20Enterprise%20Edition%20%28Use%20Partitioned%20View%29" 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%2F09%2Fsql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view%2F&amp;linkname=SQL%20Server%3A%20Implement%20Table%20Partition%20in%20Non%20Enterprise%20Edition%20%28Use%20Partitioned%20View%29" 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%2F09%2Fsql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view%2F&#038;title=SQL%20Server%3A%20Implement%20Table%20Partition%20in%20Non%20Enterprise%20Edition%20%28Use%20Partitioned%20View%29" data-a2a-url="https://www.dbrnd.com/2017/09/sql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view/" data-a2a-title="SQL Server: Implement Table Partition in Non Enterprise Edition (Use Partitioned View)"></a></p><p>In this post, I am sharing a full demonstration of the concept of Partitioned view in SQL Server.</p>
<p>Using Partitioned view, you can implement Table Partitioning in the Non-Enterprise Edition of SQL Server because Table Partition is the feature of SQL Server Enterprise Edition.</p>
<p>Many small level companies are searching for this kind of solution, and the concept of Partitioned view is also giving a good performance. </p>
<blockquote><p>We can also say that this is a manual table partitioning where you must create separate physical tables basis on your require partition ranges and require to apply proper CHECK constraint for validating data ranges. </p>
<p>After this, using one view, you can access all table and accordingly query execution plan also access only require table which reduces the unnecessary load on all or whole table. </p></blockquote>
<p>Please check the below demonstration and try it your self.</p>
<p><strong>Create a SEQUENCE object:</strong></p><pre class="crayon-plain-tag">CREATE SEQUENCE dbo.seq_ProductHistory
    START WITH 1  
    INCREMENT BY 1 ;  
GO</pre><p>
<strong>Create four physical tables:</strong></p><pre class="crayon-plain-tag">CREATE TABLE dbo.tbl_ProductHistory_Q1
(
	ProductID INT
	,ProductName VARCHAR(20)
	,SoldDate DATE
	,ProductSoldQuarter TINYINT CHECK (ProductSoldQuarter = 1)
	,CONSTRAINT pk_tbl_ProductHistory_Q1_ProductID_ProductSoldQuarter PRIMARY KEY(ProductID, ProductSoldQuarter)
)
GO

CREATE TABLE dbo.tbl_ProductHistory_Q2
(
	ProductID INT 
	,ProductName VARCHAR(20)
	,SoldDate DATE
	,ProductSoldQuarter TINYINT CHECK (ProductSoldQuarter = 2)
	,CONSTRAINT pk_tbl_ProductHistory_Q2_ProductID_ProductSoldQuarter PRIMARY KEY(ProductID, ProductSoldQuarter)
)
GO

CREATE TABLE dbo.tbl_ProductHistory_Q3
(
	ProductID INT 
	,ProductName VARCHAR(20)
	,SoldDate DATE
	,ProductSoldQuarter TINYINT CHECK (ProductSoldQuarter = 3)
	,CONSTRAINT pk_tbl_ProductHistory_Q3_ProductID_ProductSoldQuarter PRIMARY KEY(ProductID, ProductSoldQuarter)
)
GO

CREATE TABLE dbo.tbl_ProductHistory_Q4
(
	ProductID INT 
	,ProductName VARCHAR(20)
	,SoldDate DATE
	,ProductSoldQuarter TINYINT CHECK (ProductSoldQuarter = 4)
	,CONSTRAINT pk_tbl_ProductHistory_Q4_ProductID_ProductSoldQuarter PRIMARY KEY(ProductID, ProductSoldQuarter)
)
GO</pre><p>
<strong>Create a Partitioned View:</strong></p><pre class="crayon-plain-tag">CREATE VIEW dbo.vw_ProductHistory
WITH SCHEMABINDING
AS
SELECT ProductID, ProductName, SoldDate, ProductSoldQuarter FROM dbo.tbl_ProductHistory_Q1
UNION ALL
SELECT ProductID, ProductName, SoldDate, ProductSoldQuarter FROM dbo.tbl_ProductHistory_Q2
UNION ALL
SELECT ProductID, ProductName, SoldDate, ProductSoldQuarter FROM dbo.tbl_ProductHistory_Q3
UNION ALL
SELECT ProductID, ProductName, SoldDate, ProductSoldQuarter FROM dbo.tbl_ProductHistory_Q4
GO</pre><p>
<strong>Use view and Insert data into four tables:</strong></p><pre class="crayon-plain-tag">INSERT INTO dbo.vw_ProductHistory 
VALUES (NEXT VALUE FOR dbo.seq_ProductHistory, 'Computer', '2017-01-08', 1)
GO

INSERT INTO dbo.vw_ProductHistory 
VALUES (NEXT VALUE FOR dbo.seq_ProductHistory, 'Laptop', '2017-04-14', 2)
GO

INSERT INTO dbo.vw_ProductHistory 
VALUES (NEXT VALUE FOR dbo.seq_ProductHistory, 'Pendrive', '2017-08-16', 3)
GO

INSERT INTO dbo.vw_ProductHistory 
VALUES (NEXT VALUE FOR dbo.seq_ProductHistory, 'Mobile', '2017-12-26', 4)
GO</pre><p>
<strong>SELECT all records from all four tables via view:</strong><br />
Check the execution plan, where you can see four different access on physical tables.</p><pre class="crayon-plain-tag">SELECT *FROM dbo.vw_ProductHistory</pre><p>
<strong>Result:</strong></p><pre class="crayon-plain-tag">ProductID   ProductName          SoldDate   ProductSoldQuarter
----------- -------------------- ---------- ------------------
1           Computer             2017-01-08 1
2           Laptop               2017-04-14 2
3           Pendrive             2017-08-16 3
4           Mobile               2017-12-26 4</pre><p>
<strong>Check the execution plan: It is accessing all four physical tables</strong></p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-6027" src="https://www.dbrnd.com/wp-content/uploads/2017/08/PartitionedViewAllScan.png" alt="" width="539" height="391" /></p>
<p><strong>SELECT few records:</strong><br />
Check the execution plan, where you can find only access of Quarter-4 table because we are selecting data only for it.</p><pre class="crayon-plain-tag">SELECT *FROM dbo.vw_ProductHistory 
WHERE ProductSoldQuarter = 4</pre><p>
<strong>Result:</strong></p><pre class="crayon-plain-tag">ProductID   ProductName          SoldDate   ProductSoldQuarter
----------- -------------------- ---------- ------------------
4           Mobile               2017-12-26 4</pre><p>
<strong>Check the execution plan: It is accessing only Quarter-4 table.</strong></p>
<p><img decoding="async" class="alignnone size-full wp-image-6026" src="https://www.dbrnd.com/wp-content/uploads/2017/08/PartitionedViewSingalScan.png" alt="" width="582" height="131" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/09/sql-server-implement-table-partition-in-non-enterprise-edition-use-partitioned-view/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
