<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-10782889.post232139892424492339..comments</id><updated>2008-05-01T16:00:43.742+09:30</updated><category term='Vista'/><category term='Internet Safety'/><category term='Software Engineering'/><category term='SQL'/><category term='Wishlist'/><category term='Accessibility'/><category term='Family'/><category term='Podcasts'/><category term='Animals'/><category term='Friends'/><category term='ADSL'/><category term='Cycling'/><category term='Security'/><category term='LobsterPot'/><category term='Talks'/><category term='Windows Phone'/><category term='Productivity'/><category term='PowerShell'/><category term='HTPC'/><category term='ORM'/><category term='Food'/><category term='Web Browsers'/><category term='Software'/><category term='Work'/><category term='Faith'/><category term='Health'/><category term='Unit Testing'/><category term='Windows 7'/><category term='Energy'/><category term='Windows Home Server'/><category term='XBox'/><category term='UniSA'/><category term='Muppets'/><category term='WWW'/><category term='Training and Certification'/><category term='Office'/><category term='Music'/><category term='Fonts'/><category term='SharePoint'/><category term='Domain hosting'/><category term='Hyper-V'/><category term='DotNet'/><category term='Humour'/><category term='Blogger'/><category term='Media Center'/><category term='Life'/><category term='VoIP'/><category term='Conferences'/><category term='User Interfaces'/><category term='Hardware'/><category term='Transport'/><category term='Television'/><category term='PocketPC'/><category term='Media'/><category term='Books'/><category term='Excel'/><title type='text'>Comments on David Gardiner - Dave's Daydreams: Ordering data using dynamic SQL versus temporary t...</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://david.gardiner.net.au/feeds/232139892424492339/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10782889/232139892424492339/comments/default'/><link rel='alternate' type='text/html' href='http://david.gardiner.net.au/2008/05/ordering-data-using-dynamic-sql-versus.html'/><author><name>David Gardiner</name><uri>https://profiles.google.com/105745633277721273594</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-HG8IfuwP9aQ/AAAAAAAAAAI/AAAAAAAAAMU/Yd9n3ieWEu4/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-10782889.post-3878496109165756772</id><published>2008-05-01T16:00:00.000+09:30</published><updated>2008-05-01T16:00:00.000+09:30</updated><title type='text'>Hey, that is cool! I'm not sure I knew you could u...</title><content type='html'>Hey, that is cool! I'm not sure I knew you could use a CASE there.&lt;BR/&gt;&lt;BR/&gt;Thanks Jason :-)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10782889/232139892424492339/comments/default/3878496109165756772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10782889/232139892424492339/comments/default/3878496109165756772'/><link rel='alternate' type='text/html' href='http://david.gardiner.net.au/2008/05/ordering-data-using-dynamic-sql-versus.html?showComment=1209623400000#c3878496109165756772' title=''/><author><name>David Gardiner</name><uri>http://www.blogger.com/profile/02736662399117718257</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.unisanet.unisa.edu.au/staff/photos/DavidGardiner.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://david.gardiner.net.au/2008/05/ordering-data-using-dynamic-sql-versus.html' ref='tag:blogger.com,1999:blog-10782889.post-232139892424492339' source='http://www.blogger.com/feeds/10782889/posts/default/232139892424492339' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1204687854'/></entry><entry><id>tag:blogger.com,1999:blog-10782889.post-5614554558726436606</id><published>2008-05-01T14:45:00.000+09:30</published><updated>2008-05-01T14:45:00.000+09:30</updated><title type='text'>Hi David,&lt;br&gt;&lt;br&gt;As another approach, in the past ...</title><content type='html'>Hi David,&lt;BR/&gt;&lt;BR/&gt;As another approach, in the past I've handled the same situation like this:&lt;BR/&gt;&lt;BR/&gt;SELECT&lt;BR/&gt;    *&lt;BR/&gt;FROM    Table1&lt;BR/&gt;ORDER BY&lt;BR/&gt;    CASE WHEN @order = 'Column1'&lt;BR/&gt;         THEN Column1&lt;BR/&gt;         ELSE Column2 END&lt;BR/&gt;&lt;BR/&gt;Regards,</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10782889/232139892424492339/comments/default/5614554558726436606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10782889/232139892424492339/comments/default/5614554558726436606'/><link rel='alternate' type='text/html' href='http://david.gardiner.net.au/2008/05/ordering-data-using-dynamic-sql-versus.html?showComment=1209618900000#c5614554558726436606' title=''/><author><name>Jason Stangroome</name><uri>http://www.codeassassin.com</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://david.gardiner.net.au/2008/05/ordering-data-using-dynamic-sql-versus.html' ref='tag:blogger.com,1999:blog-10782889.post-232139892424492339' source='http://www.blogger.com/feeds/10782889/posts/default/232139892424492339' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1245605195'/></entry><entry><id>tag:blogger.com,1999:blog-10782889.post-4329251045938383181</id><published>2008-05-01T14:06:00.000+09:30</published><updated>2008-05-01T14:06:00.000+09:30</updated><title type='text'>Certainly the maintenance aspect was weighing on m...</title><content type='html'>Certainly the maintenance aspect was weighing on my mind.&lt;BR/&gt;&lt;BR/&gt;One other variation to throw in the mix is to make use of a table-value function to encapsulate the main query and then using that with the dynamic SQL technique. This means more of the SQL is not hidden as a string.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10782889/232139892424492339/comments/default/4329251045938383181'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10782889/232139892424492339/comments/default/4329251045938383181'/><link rel='alternate' type='text/html' href='http://david.gardiner.net.au/2008/05/ordering-data-using-dynamic-sql-versus.html?showComment=1209616560000#c4329251045938383181' title=''/><author><name>David Gardiner</name><uri>http://www.blogger.com/profile/02736662399117718257</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.unisanet.unisa.edu.au/staff/photos/DavidGardiner.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://david.gardiner.net.au/2008/05/ordering-data-using-dynamic-sql-versus.html' ref='tag:blogger.com,1999:blog-10782889.post-232139892424492339' source='http://www.blogger.com/feeds/10782889/posts/default/232139892424492339' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1204687854'/></entry><entry><id>tag:blogger.com,1999:blog-10782889.post-413433057898742320</id><published>2008-05-01T11:49:00.000+09:30</published><updated>2008-05-01T11:49:00.000+09:30</updated><title type='text'>As you say, "it depends!"&lt;br&gt;&lt;br&gt;From a maintenanc...</title><content type='html'>As you say, "it depends!"&lt;BR/&gt;&lt;BR/&gt;From a maintenance point of view, the temporary table is the only way to go. There is no safe way to maintain an SQL query (or any code) that has to be maintained in two places, or inside a string variable.&lt;BR/&gt;&lt;BR/&gt;I don't know of the performance differences, but cpu cycles are cheaper than developer sanity.&lt;BR/&gt;&lt;BR/&gt;Of course, this is a trick question! Surely you would be retrieving data into an object with it's own ordering methods.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/10782889/232139892424492339/comments/default/413433057898742320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/10782889/232139892424492339/comments/default/413433057898742320'/><link rel='alternate' type='text/html' href='http://david.gardiner.net.au/2008/05/ordering-data-using-dynamic-sql-versus.html?showComment=1209608340000#c413433057898742320' title=''/><author><name>David</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://david.gardiner.net.au/2008/05/ordering-data-using-dynamic-sql-versus.html' ref='tag:blogger.com,1999:blog-10782889.post-232139892424492339' source='http://www.blogger.com/feeds/10782889/posts/default/232139892424492339' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-189123770'/></entry></feed>
