<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Firoz Ansari's Weblog - All Comments</title><link>http://weblogs.asp.net/firoz/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Debug Build: 20510.895)</generator><item><title>re: SQL Server 2005 - Data Paging</title><link>http://weblogs.asp.net/firoz/archive/2005/06/12/411949.aspx#7107317</link><pubDate>Wed, 03 Jun 2009 18:46:38 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7107317</guid><dc:creator>firoz.ansari</dc:creator><description>&lt;p&gt;I am not sure but you don't need four separate queries for First/Prev/Next/Last link. Only one SQL statement will fetch data based on which &amp;quot;page&amp;quot; you want to show. Modified SQL will be look like this:&lt;/p&gt;
&lt;p&gt;WITH ClientList AS (&lt;/p&gt;
&lt;p&gt;SELECT ROW_NUMBER() OVER (ORDER BY CompanyID) AS RowNumber, &amp;lt;field list&amp;gt;&lt;/p&gt;
&lt;p&gt;FROM Clients&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;SELECT *&lt;/p&gt;
&lt;p&gt;FROM ClientList&lt;/p&gt;
&lt;p&gt;WHERE RowNumber between 1 and 10&lt;/p&gt;
&lt;p&gt;Put above SQL in SP and pass two additional arguments, PageIndex &amp;amp; PageSize which used to determine lower and upper record number.&lt;/p&gt;
&lt;p&gt;In SP:&lt;/p&gt;
&lt;p&gt;SET @PageLowerBound = @PageSize * @PageIndex&lt;/p&gt;
&lt;p&gt;SET @PageUpperBound = @PageLowerBound + @PageSize&lt;/p&gt;
&lt;p&gt;WITH ClientList AS (&lt;/p&gt;
&lt;p&gt;SELECT ROW_NUMBER() OVER (ORDER BY CompanyID) AS RowNumber, &amp;lt;field list&amp;gt;&lt;/p&gt;
&lt;p&gt;FROM Clients&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;SELECT *&lt;/p&gt;
&lt;p&gt;FROM ClientList&lt;/p&gt;
&lt;p&gt;WHERE RowNumber between @PageLowerBound and @PageUpperBound&lt;/p&gt;
&lt;p&gt;Page will hold the current page number. If you click on Next, add +1 to the current page and pass it to this SP. Same way, if you click on Prev, substract 1 from current page.&lt;/p&gt;
&lt;p&gt;Hope this help.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7107317" width="1" height="1"&gt;</description></item><item><title>re: SQL Server 2005 - Data Paging</title><link>http://weblogs.asp.net/firoz/archive/2005/06/12/411949.aspx#7107266</link><pubDate>Wed, 03 Jun 2009 17:52:21 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7107266</guid><dc:creator>Yahya</dc:creator><description>&lt;p&gt;Faraz, this is a related but is from access. I have four sql that bring first, next, prev and last recs respectively as below, not sure how to implement in sql server using ROW_NUMBER(), if at all this is feasible. Wonder if you can give some pointers.&lt;/p&gt;
&lt;p&gt;First&lt;/p&gt;
&lt;p&gt;SELECT TOP 1 &amp;lt;field list&amp;gt;&lt;/p&gt;
&lt;p&gt;FROM Clients&lt;/p&gt;
&lt;p&gt;WHERE (Status = @Status)&lt;/p&gt;
&lt;p&gt;ORDER BY CompanyID&lt;/p&gt;
&lt;p&gt;Next&lt;/p&gt;
&lt;p&gt;SELECT TOP 1 &amp;lt;field list&amp;gt;&lt;/p&gt;
&lt;p&gt;FROM Clients&lt;/p&gt;
&lt;p&gt;WHERE (CompanyID &amp;gt; ?) AND (Status = @Status)&lt;/p&gt;
&lt;p&gt;ORDER BY CompanyID&lt;/p&gt;
&lt;p&gt;Prev&lt;/p&gt;
&lt;p&gt;SELECT TOP 1 &amp;lt;field list&amp;gt;&lt;/p&gt;
&lt;p&gt;FROM Clients&lt;/p&gt;
&lt;p&gt;WHERE (CompanyID &amp;lt; ?) AND (Status = @Status)&lt;/p&gt;
&lt;p&gt;ORDER BY CompanyID DESC&lt;/p&gt;
&lt;p&gt;Last&lt;/p&gt;
&lt;p&gt;SELECT TOP 1 &amp;lt;field list&amp;gt;&lt;/p&gt;
&lt;p&gt;FROM Clients&lt;/p&gt;
&lt;p&gt;WHERE (Status = @Status)&lt;/p&gt;
&lt;p&gt;ORDER BY CompanyID DESC&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7107266" width="1" height="1"&gt;</description></item><item><title>re: PowerMenu – Minimizing application to system tray</title><link>http://weblogs.asp.net/firoz/archive/2005/06/13/412094.aspx#7084912</link><pubDate>Wed, 13 May 2009 14:34:56 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7084912</guid><dc:creator>CHS</dc:creator><description>&lt;p&gt;You don&amp;#39;t need a batch to add switches, just create a shortcut for the program then right click the shortcut and go to properties then edit the target to display PowerMenu.exe&amp;quot; -hideself on and drag that shortcut to the startup folder.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7084912" width="1" height="1"&gt;</description></item><item><title>re: Power of Literal Control</title><link>http://weblogs.asp.net/firoz/pages/46880.aspx#6903521</link><pubDate>Fri, 13 Feb 2009 17:31:18 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6903521</guid><dc:creator>HS</dc:creator><description>&lt;p&gt;Great Article..... I always wanted to find how to use JavaScript with Asp.net efficiently and from the code behind page....&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6903521" width="1" height="1"&gt;</description></item><item><title>re: TinySQL Code Generator</title><link>http://weblogs.asp.net/firoz/archive/2007/09/13/tinysql-code-generator.aspx#6842965</link><pubDate>Sat, 17 Jan 2009 16:29:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6842965</guid><dc:creator>Ömer Faruk Z</dc:creator><description>&lt;p&gt;cool, try codesmith&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6842965" width="1" height="1"&gt;</description></item><item><title>re: SQL Server 2005 - Data Paging</title><link>http://weblogs.asp.net/firoz/archive/2005/06/12/411949.aspx#6741560</link><pubDate>Sun, 16 Nov 2008 18:22:09 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6741560</guid><dc:creator>Estetik</dc:creator><description>&lt;p&gt;I&amp;#39;m guessing the only way to do this in Javascript would be to use the onresize event, and then using the resizeTo method to attempt to keep the window at the size you want? &lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6741560" width="1" height="1"&gt;</description></item><item><title>re: PowerMenu – Minimizing application to system tray</title><link>http://weblogs.asp.net/firoz/archive/2005/06/13/412094.aspx#6740934</link><pubDate>Sun, 16 Nov 2008 11:33:25 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6740934</guid><dc:creator>Jojo</dc:creator><description>&lt;p&gt;I run that batch file but see a dos command window popping up.&lt;/p&gt;
&lt;p&gt;I have added a vbscript file to call that batch file, then put a shortcut to the vbs file at the startup menu, so it starts up in the background when windows starts.&lt;/p&gt;
&lt;p&gt;The vbs file can be created using a notepad to copy the following and save the file as PowerMenu.vbs&lt;/p&gt;
&lt;p&gt;Set WshShell = WScript.CreateObject(&amp;quot;WScript.Shell&amp;quot;)&lt;/p&gt;
&lt;p&gt;cmd = &amp;quot;PowerMenu.bat&amp;quot;&lt;/p&gt;
&lt;p&gt;Return = WshShell.Run(cmd, 0, True)&lt;/p&gt;
&lt;p&gt;set WshShell = Nothing&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6740934" width="1" height="1"&gt;</description></item><item><title>re: SQL Server 2005 - Data Paging</title><link>http://weblogs.asp.net/firoz/archive/2005/06/12/411949.aspx#6684456</link><pubDate>Fri, 17 Oct 2008 12:37:31 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6684456</guid><dc:creator>DragonGod</dc:creator><description>&lt;p&gt;This is excellent.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6684456" width="1" height="1"&gt;</description></item><item><title>re: Power of Literal Control</title><link>http://weblogs.asp.net/firoz/pages/46880.aspx#6682623</link><pubDate>Thu, 16 Oct 2008 04:22:17 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6682623</guid><dc:creator>Crazy</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for your info on Literal Control&lt;/p&gt;
&lt;p&gt;i got good knowledge on literal control&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6682623" width="1" height="1"&gt;</description></item><item><title>re: SQL Server 2005 - Data Paging</title><link>http://weblogs.asp.net/firoz/archive/2005/06/12/411949.aspx#6119713</link><pubDate>Mon, 21 Apr 2008 21:26:25 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6119713</guid><dc:creator>Okey</dc:creator><description>&lt;p&gt;very thanks&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6119713" width="1" height="1"&gt;</description></item></channel></rss>