home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 17,731 of 19,505   
   m to mirosla...@gmail.com   
   Re: multiple column sort   
   08 Jan 10 13:16:24   
   
   70f2a065   
   From: miroslavsi@gmail.com   
      
   Thank you.   
      
   "Mark D Powell"  wrote in message   
   news:a031b83f-469a-47ad-b893-c9abbef26042@c3g2000yqd.googlegroups.com...   
   On Jan 7, 7:52 am, "m"  wrote:   
   > Hello,   
   >   
   > I need to provide sorting ability across multiple column.   
   >   
   > Data which would be sorted are retrieved with stored procedure.   
   >   
   > I have two solutions:   
   >   
   > 1. if statement   
   > depending of sort type I must create diferent select statement   
   >   
   > in case many columns there would be so many variations (also, there must   
   > be   
   > considered sort direction ASC or DESC what increase variations double)   
   >   
   > 2. dynamic sql   
   >   
   > Is there any additional way, which one is better?   
   >   
   > Please advice,   
   >   
   > Best regards   
      
   Generally speaking static SQL is preferable to dynamic SQL.  However,   
   there are times when dynamic SQL comes in handy.  If you have only a   
   couple of possible orderings I would go with static SQL.  If you have   
   numerous possible desired orderings with varying order by column lists   
   then I would build the order by clause in the procedure logic.   
      
   Just make sure you are not trying to do too much in a single procedure   
   and that all the SQL's in question are really just variations of one   
   basic query rather than trying to code logic to accomodate several   
   different basic queries that just happen to use the same source   
   tables.   
      
   HTH -- Mark D Powell --   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca