Parameters as ORDER BY

Results 1 to 2 of 2

Thread: Parameters as ORDER BY

  1. #1
    Join Date
    Dec 1969

    Default Parameters as ORDER BY

    Sorry, posting this again because I have noticed in this forum that if a question has an answer posted - sometimes no-one else looks at the question. If the answer posted did not help - you don&#039;t get an answer.<BR>I want to sort a recordset in the same order as the parameters I pass to it. If I use a WHERE clause such as: <BR>WHERE ProductID = 9 or 5 or 15 <BR>I want the resulting recordset to be sorted in the order of the parameters. At the moment the recordset displays in the same order as the data in the table. How can I make it sort in the same order as the parameters I pass to it?

  2. #2
    Join Date
    Dec 1969

    Default RE: Parameters as ORDER BY

    assuming you are using sql server stored procs<BR><BR>create a temp table to hold the returned data with an extra row<BR>ordering int indentity (1,1) <BR><BR>then populate this temp table based on your parameters<BR><BR>then select out of the temp table ordering by [ordering] or whatever you decide to call it.<BR><BR>This&#039;ll work but I am not sure it is what you want

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts