<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) &#8211; CTE vs. Derived Table</title>
	<atom:link href="http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nandish</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-57079</link>
		<dc:creator>Nandish</dc:creator>
		<pubDate>Tue, 27 Oct 2009 14:18:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-57079</guid>
		<description>Hi Pinal,

Great query...

Fantastic..it works perfactly...</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Great query&#8230;</p>
<p>Fantastic..it works perfactly&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Faisal</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-56847</link>
		<dc:creator>Faisal</dc:creator>
		<pubDate>Wed, 21 Oct 2009 10:14:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-56847</guid>
		<description>Great Query.. 

I think u&#039;r master of Query.. hahaha

Thank u  very much... :)</description>
		<content:encoded><![CDATA[<p>Great Query.. </p>
<p>I think u&#8217;r master of Query.. hahaha</p>
<p>Thank u  very much&#8230; :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Guidelines and Coding Standards Part - 1 Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-47496</link>
		<dc:creator>SQL SERVER - Guidelines and Coding Standards Part - 1 Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Thu, 26 Feb 2009 12:13:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-47496</guid>
		<description>[...] Avoid using temporary tables and derived tables as it uses more disks I/O. Instead use CTE (Common Table Expression); its scope is limited to the next statement in SQL query. (Read More Here) [...]</description>
		<content:encoded><![CDATA[<p>[...] Avoid using temporary tables and derived tables as it uses more disks I/O. Instead use CTE (Common Table Expression); its scope is limited to the next statement in SQL query. (Read More Here) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-47220</link>
		<dc:creator>SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Tue, 24 Feb 2009 12:09:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-47220</guid>
		<description>[...] SQL SERVER - 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) - CTE vs. Derived ... [...]</description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) &#8211; CTE vs. Derived &#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chip H</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-45535</link>
		<dc:creator>Chip H</dc:creator>
		<pubDate>Sun, 11 Jan 2009 17:47:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-45535</guid>
		<description>Note that because of the inner ORDER BY clause the entire table will need to be sorted prior to the CTE with it&#039;s ROW_NUMBER value being used.  This is a good time to have an alternate index on the columns you&#039;re ordering by. :)

You can verify this by examining the execution plan before and after adding the alternate index.  Don&#039;t forget to do a ALTER INDEX {alternateindexname} ON {tablename} REBUILD prior to examining the plan so that SQL Server has fresh statistics to work with.</description>
		<content:encoded><![CDATA[<p>Note that because of the inner ORDER BY clause the entire table will need to be sorted prior to the CTE with it&#8217;s ROW_NUMBER value being used.  This is a good time to have an alternate index on the columns you&#8217;re ordering by. :)</p>
<p>You can verify this by examining the execution plan before and after adding the alternate index.  Don&#8217;t forget to do a ALTER INDEX {alternateindexname} ON {tablename} REBUILD prior to examining the plan so that SQL Server has fresh statistics to work with.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: C.P.Usman</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-43907</link>
		<dc:creator>C.P.Usman</dc:creator>
		<pubDate>Sat, 25 Oct 2008 08:54:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-43907</guid>
		<description>The post is very usefull and so much thanks.
here i have one more doubts that how I can send criteria (dynamic) to this qeury. I want to show the result by page. But the result for some particular conditions. If you have any idea.. Please give me some shot.


thanks again</description>
		<content:encoded><![CDATA[<p>The post is very usefull and so much thanks.<br />
here i have one more doubts that how I can send criteria (dynamic) to this qeury. I want to show the result by page. But the result for some particular conditions. If you have any idea.. Please give me some shot.</p>
<p>thanks again</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manjunath</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-35138</link>
		<dc:creator>Manjunath</dc:creator>
		<pubDate>Wed, 16 Apr 2008 13:05:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-35138</guid>
		<description>Hi Pinal,

I have a table with 2 million records, i have created a Full text Index on a nvarchar column &#039;itemName&#039; of size 70. When i do a query like:


WITH ListTemp AS (Select ROW_NUMBER() OVER( ORDER BY [main].[itemName] ASC) as rownum,  
main.itemname,main.itemdescription
FROM 
CONTAINSTABLE([ItemTemp1], itemname, &#039;chevrolet&#039;) AS A
join [ItemTemp1] main on a.[key] = main.id
)
SELECT * FROM ListTemp WHERE rownum &gt; 0 AND rownum &lt;11 ORDER BY rownum

it takes more than a minute to execute.

While a query like:

select main.itemname,main.itemdescription
FROM CONTAINSTABLE([ItemTemp1], itemname, &#039;chevrolet&#039;) AS A
join [ItemTemp1] main on a.[key] = main.id

executes in a few seconds.

Will not a full text search perform well when placed in a CTE?</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I have a table with 2 million records, i have created a Full text Index on a nvarchar column &#8216;itemName&#8217; of size 70. When i do a query like:</p>
<p>WITH ListTemp AS (Select ROW_NUMBER() OVER( ORDER BY [main].[itemName] ASC) as rownum,<br />
main.itemname,main.itemdescription<br />
FROM<br />
CONTAINSTABLE([ItemTemp1], itemname, &#8216;chevrolet&#8217;) AS A<br />
join [ItemTemp1] main on a.[key] = main.id<br />
)<br />
SELECT * FROM ListTemp WHERE rownum &gt; 0 AND rownum &lt;11 ORDER BY rownum</p>
<p>it takes more than a minute to execute.</p>
<p>While a query like:</p>
<p>select main.itemname,main.itemdescription<br />
FROM CONTAINSTABLE([ItemTemp1], itemname, &#8216;chevrolet&#8217;) AS A<br />
join [ItemTemp1] main on a.[key] = main.id</p>
<p>executes in a few seconds.</p>
<p>Will not a full text search perform well when placed in a CTE?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adi Gaber</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-34739</link>
		<dc:creator>Adi Gaber</dc:creator>
		<pubDate>Mon, 31 Mar 2008 23:20:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-34739</guid>
		<description>Check out my blog for a solution to fetching the last page efficiently.</description>
		<content:encoded><![CDATA[<p>Check out my blog for a solution to fetching the last page efficiently.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arnab Mukherjee</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-33567</link>
		<dc:creator>Arnab Mukherjee</dc:creator>
		<pubDate>Thu, 07 Feb 2008 10:17:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-33567</guid>
		<description>The code is pretty simple. But the problem is that it sorts the data that is coming out. And OVER() method needs an &quot;order by&quot; in it&#039;s parameter. So if we want the data as it is in the database it is not possible in this way. If there is any way to eliminate the sorting then i think the code will be more appropriate.</description>
		<content:encoded><![CDATA[<p>The code is pretty simple. But the problem is that it sorts the data that is coming out. And OVER() method needs an &#8220;order by&#8221; in it&#8217;s parameter. So if we want the data as it is in the database it is not possible in this way. If there is any way to eliminate the sorting then i think the code will be more appropriate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-33422</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Fri, 01 Feb 2008 21:06:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-33422</guid>
		<description>You could always use &quot;top&quot; to limit the number of rows returned by the subquery...then you would only have the massive derived table if you actually paged to the end of the data.</description>
		<content:encoded><![CDATA[<p>You could always use &#8220;top&#8221; to limit the number of rows returned by the subquery&#8230;then you would only have the massive derived table if you actually paged to the end of the data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-33131</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Sat, 19 Jan 2008 21:40:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-33131</guid>
		<description>So it&#039;s creating a Derived Table, almost like a temp table and creating a row number column?


What happens if you have to page through 50,000 rows???

First it will create a massive 50,000 row  Derived  table - with the row number column, then you select from the Derived table.

Can&#039;t see that being good for memory or cpu performance.

Any other solutions?</description>
		<content:encoded><![CDATA[<p>So it&#8217;s creating a Derived Table, almost like a temp table and creating a row number column?</p>
<p>What happens if you have to page through 50,000 rows???</p>
<p>First it will create a massive 50,000 row  Derived  table &#8211; with the row number column, then you select from the Derived table.</p>
<p>Can&#8217;t see that being good for memory or cpu performance.</p>
<p>Any other solutions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vijayyande</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-10088</link>
		<dc:creator>vijayyande</dc:creator>
		<pubDate>Wed, 29 Aug 2007 10:27:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-10088</guid>
		<description>Hi pinal


Thanks for your valuable suggestion about paging. I am very thankful for that. 


Please suggest some good method to do paging for sql server 2000.  


thanks
vijay</description>
		<content:encoded><![CDATA[<p>Hi pinal</p>
<p>Thanks for your valuable suggestion about paging. I am very thankful for that. </p>
<p>Please suggest some good method to do paging for sql server 2000.  </p>
<p>thanks<br />
vijay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: K. Shiva Prakash</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-4520</link>
		<dc:creator>K. Shiva Prakash</dc:creator>
		<pubDate>Tue, 10 Jul 2007 05:40:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-4520</guid>
		<description>Hello, Pinal , 

        I am facing one problem. I did the paging is MSSQL 2005. and now i binded it to the controls ( returned datasets). When i clicked on the next page then, is i have to come back to the sqlserver with new startrow and endrow values ?.</description>
		<content:encoded><![CDATA[<p>Hello, Pinal , </p>
<p>        I am facing one problem. I did the paging is MSSQL 2005. and now i binded it to the controls ( returned datasets). When i clicked on the next page then, is i have to come back to the sqlserver with new startrow and endrow values ?.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ajax Database Best Practices  Joey JavaScript</title>
		<link>http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-3799</link>
		<dc:creator>Ajax Database Best Practices  Joey JavaScript</dc:creator>
		<pubDate>Tue, 19 Jun 2007 03:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/#comment-3799</guid>
		<description>[...] 9) If retrieving multiple rows, always use database paging techniques to retrieve only the rows which are necessary (displayed on screen). Click here for more information on how to do this  [...]
</description>
		<content:encoded><![CDATA[<p>[...] 9) If retrieving multiple rows, always use database paging techniques to retrieve only the rows which are necessary (displayed on screen). Click here for more information on how to do this  [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
