<?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/"
		>
<channel>
	<title>Comments on: Slightly more dynamic ORDER BY in SQL Server 2005</title>
	<atom:link href="http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/feed/" rel="self" type="application/rss+xml" />
	<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/</link>
	<description></description>
	<lastBuildDate>Sun, 05 Sep 2010 17:46:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: SandraMillhouse</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14969</link>
		<dc:creator>SandraMillhouse</dc:creator>
		<pubDate>Thu, 24 Jun 2010 14:02:53 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14969</guid>
		<description>This is indeed a better way to order a column. Still, the difference isn&#039;t that big so I don&#039;t see why anyone should bother. Or maybe the difference is noticeable in a very large database. &lt;br&gt;Sandra @ &lt;a href=&quot;http://www.webfusion.co.uk/virtual-private-servers/&quot; rel=follow rel=&quot;nofollow&quot;&gt;Cheap VPS&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>This is indeed a better way to order a column. Still, the difference isn&#39;t that big so I don&#39;t see why anyone should bother. Or maybe the difference is noticeable in a very large database. <br />Sandra @ <a href="http://www.webfusion.co.uk/virtual-private-servers/" rel=follow rel="nofollow">Cheap VPS</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: public records</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14957</link>
		<dc:creator>public records</dc:creator>
		<pubDate>Mon, 10 May 2010 12:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14957</guid>
		<description>Slightly more dynamic ORDER BY in SQL Server. Hey Jeff, thanks for the link. I originally developed this method for use with pretty.</description>
		<content:encoded><![CDATA[<p>Slightly more dynamic ORDER BY in SQL Server. Hey Jeff, thanks for the link. I originally developed this method for use with pretty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miguel_TX</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14874</link>
		<dc:creator>Miguel_TX</dc:creator>
		<pubDate>Wed, 27 May 2009 03:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14874</guid>
		<description>I forgot to mention that this way should also work in SQL Server 2000 for anyone still using that.</description>
		<content:encoded><![CDATA[<p>I forgot to mention that this way should also work in SQL Server 2000 for anyone still using that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miguel_TX</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14873</link>
		<dc:creator>Miguel_TX</dc:creator>
		<pubDate>Wed, 27 May 2009 03:47:28 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14873</guid>
		<description>I just tried this way of sorting and for the query I was running (a very big one) it took twice as long to run than it did with my own dynamic sorting.&lt;br&gt;&lt;br&gt;Everyone, please use this instead - it&#039;s faster when it counts:&lt;br&gt;    ORDER BY&lt;br&gt;         (CASE  WHEN @CustomerTypeID = 1 THEN FirstName END), &lt;br&gt;         (CASE  WHEN @CustomerTypeID = 1 THEN LastName  END),&lt;br&gt;         (CASE  WHEN @CustomerTypeID = 2 THEN LastName  END), &lt;br&gt;         (CASE  WHEN @CustomerTypeID = 2 THEN FirstName END),&lt;br&gt;         (CASE  WHEN @CustomerTypeID = 3 THEN LastName  END) DESC, &lt;br&gt;         (CASE  WHEN @CustomerTypeID = 3 THEN FirstName END) DESC&lt;br&gt;&lt;br&gt;I ask that the author of this post (John Sheehan) try it and update this post with his findings if he finds that it works better.  Thank you.&lt;br&gt;&lt;br&gt;I can&#039;t take credit for this way of doing it as I found it months ago on another posting - but I can&#039;t remember where.&lt;br&gt;&lt;br&gt;                    - Miguel_TX</description>
		<content:encoded><![CDATA[<p>I just tried this way of sorting and for the query I was running (a very big one) it took twice as long to run than it did with my own dynamic sorting.</p>
<p>Everyone, please use this instead &#8211; it&#39;s faster when it counts:<br />    ORDER BY<br />         (CASE  WHEN @CustomerTypeID = 1 THEN FirstName END), <br />         (CASE  WHEN @CustomerTypeID = 1 THEN LastName  END),<br />         (CASE  WHEN @CustomerTypeID = 2 THEN LastName  END), <br />         (CASE  WHEN @CustomerTypeID = 2 THEN FirstName END),<br />         (CASE  WHEN @CustomerTypeID = 3 THEN LastName  END) DESC, <br />         (CASE  WHEN @CustomerTypeID = 3 THEN FirstName END) DESC</p>
<p>I ask that the author of this post (John Sheehan) try it and update this post with his findings if he finds that it works better.  Thank you.</p>
<p>I can&#39;t take credit for this way of doing it as I found it months ago on another posting &#8211; but I can&#39;t remember where.</p>
<p>                    &#8211; Miguel_TX</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miguel_TX</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14696</link>
		<dc:creator>Miguel_TX</dc:creator>
		<pubDate>Tue, 26 May 2009 22:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14696</guid>
		<description>I forgot to mention that this way should also work in SQL Server 2000 for anyone still using that.</description>
		<content:encoded><![CDATA[<p>I forgot to mention that this way should also work in SQL Server 2000 for anyone still using that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miguel_TX</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14695</link>
		<dc:creator>Miguel_TX</dc:creator>
		<pubDate>Tue, 26 May 2009 22:47:28 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14695</guid>
		<description>I just tried this way of sorting and for the query I was running (a very big one) it took twice as long to run than it did with my own dynamic sorting.&lt;br&gt;&lt;br&gt;Everyone, please use this instead - it&#039;s faster when it counts:&lt;br&gt;    ORDER BY&lt;br&gt;         (CASE  WHEN @CustomerTypeID = 1 THEN FirstName END), &lt;br&gt;         (CASE  WHEN @CustomerTypeID = 1 THEN LastName  END),&lt;br&gt;         (CASE  WHEN @CustomerTypeID = 2 THEN LastName  END), &lt;br&gt;         (CASE  WHEN @CustomerTypeID = 2 THEN FirstName END),&lt;br&gt;         (CASE  WHEN @CustomerTypeID = 3 THEN LastName  END) DESC, &lt;br&gt;         (CASE  WHEN @CustomerTypeID = 3 THEN FirstName END) DESC&lt;br&gt;&lt;br&gt;I ask that the author of this post (John Sheehan) try it and update this post with his findings if he finds that it works better.  Thank you.&lt;br&gt;&lt;br&gt;I can&#039;t take credit for this way of doing it as I found it months ago on another posting - but I can&#039;t remember where.&lt;br&gt;&lt;br&gt;                    - Miguel_TX</description>
		<content:encoded><![CDATA[<p>I just tried this way of sorting and for the query I was running (a very big one) it took twice as long to run than it did with my own dynamic sorting.</p>
<p>Everyone, please use this instead &#8211; it&#39;s faster when it counts:<br />    ORDER BY<br />         (CASE  WHEN @CustomerTypeID = 1 THEN FirstName END), <br />         (CASE  WHEN @CustomerTypeID = 1 THEN LastName  END),<br />         (CASE  WHEN @CustomerTypeID = 2 THEN LastName  END), <br />         (CASE  WHEN @CustomerTypeID = 2 THEN FirstName END),<br />         (CASE  WHEN @CustomerTypeID = 3 THEN LastName  END) DESC, <br />         (CASE  WHEN @CustomerTypeID = 3 THEN FirstName END) DESC</p>
<p>I ask that the author of this post (John Sheehan) try it and update this post with his findings if he finds that it works better.  Thank you.</p>
<p>I can&#39;t take credit for this way of doing it as I found it months ago on another posting &#8211; but I can&#39;t remember where.</p>
<p>                    &#8211; Miguel_TX</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Sheehan</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14664</link>
		<dc:creator>John Sheehan</dc:creator>
		<pubDate>Mon, 23 Mar 2009 21:02:09 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14664</guid>
		<description>Sorry, I don&#039;t know off hand. Try &lt;a href=&quot;http://stackoverflow.com&quot; rel=&quot;nofollow&quot;&gt;stackoverflow.com&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Sorry, I don&#39;t know off hand. Try <a href="http://stackoverflow.com" rel="nofollow">stackoverflow.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: li</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14663</link>
		<dc:creator>li</dc:creator>
		<pubDate>Mon, 23 Mar 2009 08:00:34 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14663</guid>
		<description>How can I use&lt;br&gt; &lt;br&gt;ORDER BY &lt;br&gt;CASE @AccountOperator&lt;br&gt;WHEN &#039;&gt;&#039; THEN UserLastName&lt;br&gt;END ASC,&lt;br&gt;CASE @AccountOperator&lt;br&gt;WHEN &#039;&lt;&#039; THEN UserFirstName&lt;br&gt;END DESC&lt;br&gt;&lt;br&gt;when UserLastName is an alias?(without using sub query)</description>
		<content:encoded><![CDATA[<p>How can I use</p>
<p>ORDER BY <br />CASE @AccountOperator<br />WHEN &#39;&gt;&#39; THEN UserLastName<br />END ASC,<br />CASE @AccountOperator<br />WHEN &#39;&lt;&#39; THEN UserFirstName<br />END DESC</p>
<p>when UserLastName is an alias?(without using sub query)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14640</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Thu, 12 Feb 2009 06:49:41 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14640</guid>
		<description>Great work, thanks!</description>
		<content:encoded><![CDATA[<p>Great work, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mab</title>
		<link>http://john-sheehan.com/blog/slightly-more-dynamic-order-by-in-sql-server-2005/comment-page-1/#comment-14614</link>
		<dc:creator>Mab</dc:creator>
		<pubDate>Wed, 14 Jan 2009 16:50:16 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/index.php/slightly-more-dynamic-order-by-in-sql-server-2005/#comment-14614</guid>
		<description>Thanks for the article. &lt;br&gt;Just a quick question. Is it possible to write this dynamic Order By with DISTINCT, as I am getting error with DISTINCT in my select statement.</description>
		<content:encoded><![CDATA[<p>Thanks for the article. <br />Just a quick question. Is it possible to write this dynamic Order By with DISTINCT, as I am getting error with DISTINCT in my select statement.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
